Skip to content

[release/10.0] Fix multi-org GitHub App installation selection - #17440

Merged
missymessa merged 1 commit into
dotnet:release/10.0from
missymessa:missymessa/backport-pr17402-release-10.0
Aug 31, 2026
Merged

missymessa merged 1 commit into
dotnet:release/10.0from
missymessa:missymessa/backport-pr17402-release-10.0

Conversation

@missymessa

Copy link
Copy Markdown
Member

Backport of #17402.

The release branch still wraps the Invoke-RestMethod response with @(), which can retain a top-level installation array as one nested object. Explicitly enumerate each response so owner filtering selects the requested GitHub App installation.

Validation:

  • PowerShell Core syntax parsing passes
  • Windows PowerShell syntax parsing passes
  • git diff --check passes

Tracking: AB#11966

Backport of dotnet#17402.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: c08e3391-52d8-42e3-ad8c-ef2e5be92291
@missymessa
missymessa requested review from mmitche and a lite review from Copilot August 28, 2026 14:39

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

Backports a fix to Get-GitHubAppToken.ps1 to correctly select the intended GitHub App installation when the App is installed in multiple organizations by flattening paginated Invoke-RestMethod responses before owner filtering.

Changes:

  • Accumulate installations by explicitly enumerating each Invoke-RestMethod page response into a list (avoids nested top-level array behavior).
  • Track page size via a per-page enumeration count to drive pagination (while count == 100).

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

Comment on lines 115 to 119
do {
# Assign the response before wrapping it in @(). PowerShell otherwise
# preserves a top-level JSON array as one nested pipeline object.
$pageResponse = Invoke-RestMethod `
-Uri "https://api.github.com/app/installations?per_page=100&page=$page" `
-Headers $headers `
-Method Get
@missymessa
missymessa merged commit c642c36 into dotnet:release/10.0 Aug 31, 2026
11 checks passed
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