Skip to content

Commit 2278c7f

Browse files
authored
Fix OneLoc GitHub App installation selection (#14917)
OneLoc currently receives a token for the first GitHub App installation (microsoft) instead of selecting the requested dotnet installation. That causes 403 Resource not accessible by integration when localization tries to create locfiles/* branches or update PRs. This syncs the focused installation-selection fix already merged in dotnet/arcade#17312 and propagated to dotnet/dotnet main. It flattens the installations response before filtering, requires exactly one owner match, and logs the selected installation. Evidence: - The App-token step succeeds, but OneLoc branch/PR writes fail with 403. - Replaying the same operation with the correctly selected dotnet installation token succeeds. - The change is limited to �ng/common/Get-GitHubAppToken.ps1 (14 insertions, 4 deletions). ###### Microsoft Reviewers: [Open in CodeFlow](https://microsoft.github.io/open-pr/?codeflow=https://github.com/dotnet/winforms/pull/14917)
1 parent af0c793 commit 2278c7f

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

eng/common/Get-GitHubAppToken.ps1

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,13 @@ try {
113113
$installations = @()
114114
$page = 1
115115
do {
116-
$pageInstallations = @(Invoke-RestMethod `
116+
# Assign the response before wrapping it in @(). PowerShell otherwise
117+
# preserves a top-level JSON array as one nested pipeline object.
118+
$pageResponse = Invoke-RestMethod `
117119
-Uri "https://api.github.com/app/installations?per_page=100&page=$page" `
118120
-Headers $headers `
119-
-Method Get)
121+
-Method Get
122+
$pageInstallations = @($pageResponse)
120123
$installations += $pageInstallations
121124
$page++
122125
} while ($pageInstallations.Count -eq 100)
@@ -125,12 +128,19 @@ catch {
125128
Write-PipelineTelemetryError -Category 'Build' -Message "Failed to list GitHub App installations: $_. The signed JWT may be invalid or the App's Client ID ('$AppClientId') may be incorrect."
126129
exit 1
127130
}
128-
$installation = $installations | Where-Object { $_.account.login -ieq $InstallationOwner } | Select-Object -First 1
129-
if (-not $installation) {
131+
$matchingInstallations = @($installations | Where-Object { $_.account.login -ieq $InstallationOwner })
132+
if ($matchingInstallations.Count -eq 0) {
130133
$found = ($installations | ForEach-Object { $_.account.login }) -join ', '
131134
Write-PipelineTelemetryError -Category 'Build' -Message "No installation found for '$InstallationOwner'. App is installed on: $found"
132135
exit 1
133136
}
137+
if ($matchingInstallations.Count -ne 1) {
138+
$matchingIds = ($matchingInstallations | ForEach-Object { $_.id }) -join ', '
139+
Write-PipelineTelemetryError -Category 'Build' -Message "Found multiple installations for '$InstallationOwner': $matchingIds"
140+
exit 1
141+
}
142+
$installation = $matchingInstallations[0]
143+
Write-Host "Using installation $($installation.id) for '$($installation.account.login)'."
134144

135145
try {
136146
$tokenResponse = Invoke-RestMethod `

0 commit comments

Comments
 (0)