Repository navigation
Fix multi-org GitHub App installation selection - #17402
Conversation
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
There was a problem hiding this comment.
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.
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
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
|
Added regression coverage in commit 3b548a5. The tests execute the same extracted pagination and selection functions used by Get-GitHubAppToken.ps1 and cover:
Arcade PR validation now runs the suite under both Windows PowerShell and PowerShell Core on Linux. |
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
Co-authored-by: Copilot <[email protected]> Copilot-Session: 040f9d82-5d74-492a-a03d-71f0143afb36
Summary
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
AB#11966