Skip to content

Fix multi-org GitHub App installation selection - #17402

Merged
missymessa merged 7 commits into
mainfrom
users/mjanecke/fix-github-app-installation-selection
Aug 25, 2026
Merged

missymessa merged 7 commits into
mainfrom
users/mjanecke/fix-github-app-installation-selection

Conversation

@missymessa

Copy link
Copy Markdown
Member

Summary

  • flatten paginated GitHub App installation responses before filtering by organization
  • prevent OneLoc from using the first installation after the App is installed in multiple organizations

Failure

After the OneLoc App was installed in both microsoft and dotnet, the helper retained the response array as one nested object. Filtering for dotnet therefore kept the full array and token minting selected the first (microsoft) installation. Public dotnet/* reads succeeded anonymously, but PR writes failed with 403 Resource not accessible by integration across rolling builds.

Current runtime example: https://dev.azure.com/dnceng/internal/_build/results?buildId=3056284
Discussion: #17258 (comment)

Validation

  • PowerShell syntax parsing succeeds
  • fixed selection enumerates both live installations and selects exactly dotnet installation 149883392`n- a token minted from that installation successfully updates the existing runtime localization PR

AB#11966

Flatten each GitHub App installation response before filtering by owner so OneLoc mints tokens for the requested organization. AB#11966

Co-authored-by: Copilot <[email protected]>

Copilot-Session: da8d9de8-a721-469a-b877-1b5a4e09eb85
Copilot AI lite review requested due to automatic review settings August 24, 2026 20:33

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes GitHub App installation selection in Get-GitHubAppToken.ps1 to correctly handle Apps installed in multiple organizations by ensuring paginated installation results are flattened before filtering by the requested org/owner, preventing token minting from accidentally using the first installation in the unflattened response.

Changes:

  • Switch installation accumulation from array concatenation to a List[object] to avoid nested-array behavior and improve pagination handling.
  • Add per-installation insertion logic intended to ensure the installations collection is flattened before filtering by $InstallationOwner.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread eng/common/Get-GitHubAppToken.ps1 Resolved
Ensure each paginated response is unwrapped through the PowerShell pipeline before installations are counted and added.

Co-authored-by: Copilot <[email protected]>

Copilot-Session: da8d9de8-a721-469a-b877-1b5a4e09eb85
Copilot AI review requested due to automatic review settings August 24, 2026 20:59

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

Exercise exact owner selection across multi-organization and paginated installation responses on Windows PowerShell and PowerShell Core.

Co-authored-by: Copilot <[email protected]>

Copilot-Session: da8d9de8-a721-469a-b877-1b5a4e09eb85
@missymessa

Copy link
Copy Markdown
Member Author

Added regression coverage in commit 3b548a5. The tests execute the same extracted pagination and selection functions used by Get-GitHubAppToken.ps1 and cover:

  • selecting each organization when an App has multiple installations
  • selecting an organization returned on a later API page
  • missing and empty installation responses
  • duplicate installations for one owner

Arcade PR validation now runs the suite under both Windows PowerShell and PowerShell Core on Linux.

Copilot AI review requested due to automatic review settings August 24, 2026 21:07

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

Comment thread eng/common/github-app-functions.ps1 Resolved
Expose a snapshot rather than the mutable collection used while accumulating paginated responses.

Co-authored-by: Copilot <[email protected]>

Copilot-Session: da8d9de8-a721-469a-b877-1b5a4e09eb85
Copilot AI review requested due to automatic review settings August 24, 2026 21:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

@missymessa
missymessa enabled auto-merge (squash) August 24, 2026 21:22
Comment thread eng/common/Get-GitHubAppToken.ps1 Resolved
Co-authored-by: Copilot <[email protected]>
Copilot-Session: 040f9d82-5d74-492a-a03d-71f0143afb36
Copilot AI review requested due to automatic review settings August 24, 2026 21:35

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

@missymessa
missymessa requested a review from mmitche August 24, 2026 23:53
Copilot AI review requested due to automatic review settings August 25, 2026 13:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

Copilot AI review requested due to automatic review settings August 25, 2026 14:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants