Repository navigation
Conversation
…point requesters at /azp run while sign-in is blocked - Trim the PAT secret; treat Azure DevOps' 401 or 203 sign-in page as a rejected PAT and fall back to the federated identity instead of failing (a 203 was previously misread as a queued build). - On any sign-in failure, the PR comment now says to use /azp run maui-pr-uitests for the full suite instead of retrying /review run-tests, which cannot succeed while Conditional Access blocks the identity (AADSTS53003). - Document AADSTS53003 and the PAT failure modes. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 40501Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 40501" |
|
Azure Pipelines: 1 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
There was a problem hiding this comment.
🟡 Changes recommended
Credential fallback can repeat a non-idempotent queue POST after a successful response without a build ID, risking duplicate builds.
3 open issues
What changed in this PR
This CI follow-up to #40492 and #40485 improves credential recovery and failure guidance for /review run-tests, which queues targeted MAUI UI tests.
Changes:
- Trims the optional PAT and adds federated-identity fallback when Azure DevOps rejects it.
- Detects invalid queue responses and directs users to
/azp run maui-pr-uitestswhen sign-in fails. - Documents Conditional Access errors and PAT troubleshooting.
| File | Description |
|---|---|
.github/scripts/Invoke-RunTests.ps1 |
Adds PAT recovery, response validation, and sign-in failure guidance. |
.github/docs/trigger-azdo-pipeline-setup.md |
Adds troubleshooting guidance for blocked sign-in and rejected PATs. |
Review effort: Balanced
| $build = Invoke-RestMethod -Method Post -Uri "$($base)?api-version=7.1" -Headers $headers ` | ||
| -ContentType 'application/json' -Body $body -TimeoutSec 60 -StatusCodeVariable patStatus | ||
| # Azure DevOps answers an unusable PAT with 203 and its HTML sign-in page. | ||
| if ($patStatus -eq 203 -or -not $build.id) { throw [System.UnauthorizedAccessException]::new("HTTP $patStatus") } |
| | `403` from AzDO REST API | Missing permissions | Ensure the identity has "Queue builds" on the specific pipeline AND Basic access level. | | ||
| | `OIDC environment variables not available` | Missing `id-token: write` permission | Add `permissions: { id-token: write }` at the **job** level (not workflow level). | | ||
| | `Failed to get Azure AD token` | Wrong client_id/tenant_id or federated credential mismatch | Verify secrets match the MI's Client ID and Tenant ID. Check federated credential subject matches the actual OIDC claim. | | ||
| | `AADSTS53003: Access has been blocked by Conditional Access policies` | A tenant Conditional Access policy refuses token issuance to the identity from GitHub-hosted runners (seen from 2026-11-20 for `/review`, `/review gate` and `/review run-tests`). Retrying or changing the request does not help. | A tenant admin must exempt the identity (`AZDO_TRIGGER_CLIENT_ID`) from the policy. Meanwhile `/azp run maui-pr-uitests` (Azure Pipelines app) runs the full UI suite. | |
| if ($patStatus -eq 203 -or -not $build.id) { throw [System.UnauthorizedAccessException]::new("HTTP $patStatus") } | ||
| } catch { | ||
| $status = [int]$_.Exception.Response?.StatusCode | ||
| if ($_.Exception -isnot [System.UnauthorizedAccessException] -and $status -ne 401) { throw } |
|
/review expert-review-with-gate |
|
Warning Your |
| $build = Invoke-RestMethod -Method Post -Uri "$($base)?api-version=7.1" -Headers $headers ` | ||
| -ContentType 'application/json' -Body $body -TimeoutSec 60 -StatusCodeVariable patStatus | ||
| # Azure DevOps answers an unusable PAT with 203 and its HTML sign-in page. | ||
| if ($patStatus -eq 203 -or -not $build.id) { throw [System.UnauthorizedAccessException]::new("HTTP $patStatus") } |
There was a problem hiding this comment.
[major] Logic and Correctness Verification - A successful PAT queue response with an empty body or missing id is treated as an authentication rejection: the catch clears $build and the federated path repeats the same non-idempotent POST. If the first request created a build but its response omitted the ID, a second build is queued and the first remains untracked, outside selection/SHA verification and cancellation. Restrict fallback to confirmed authentication rejection (401/203); a successful response without an ID must report an unknown queue outcome without another POST. Add mocked dispatcher regression tests asserting queue-call counts for trimmed PAT success, 401/203 fallback, and timeout/500 or successful responses missing an ID. RunTests.Tests.ps1 currently tests the token helper and dispatcher source text, not this queue path.
| $queueError = "Could not sign in to Azure DevOps ($(Format-RunTestsText $_.Exception.Message 250)). $signInHelp" | ||
| } elseif ([int]$_.Exception.Response?.StatusCode -eq 401) { | ||
| Write-Warning "Azure DevOps refused the credentials: $($_.Exception.Message)" | ||
| $queueError = "Azure DevOps refused the trigger credentials (HTTP 401). $signInHelp" |
There was a problem hiding this comment.
[moderate] Logic and Correctness Verification - This 401 handler also catches the cancellation PATCH after a successful queue POST. If the returned selection or sourceVersion is wrong and cancellation returns 401, the unexpected build has already been queued and was not cancelled. The new guidance nevertheless asserts 'Nothing was queued', and the outer catch discards the build ID. Distinguish cancellation failure after confirmed queueing from authentication failure before queueing; retain the build link and report that the unexpected run may still be active.


Note
Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!
Target Branch
mainnet11, for reviewCI workflow infrastructure follow-up to #40492 and #40485. The workflow runs only from
main, so this targetsmain.For .NET 11 fixes, only a maintainer retargets the approved PR to the active
inflight lane and merges it after CI validates that final base. Do not merge
individual fixes directly into
net11; agents must not retarget or merge.Description of Change
Why
/review run-testsstill doesn't queue UI tests after #40492I checked the raw logs of every
review-run-tests-dispatchrun:AADSTS53003: Access has been blocked by Conditional Access policieson every attemptAZDO_TRIGGER_PAT(#40492)401 (Unauthorized)from Azure DevOps. The secret was removed afterwards, so later runs used OIDC again and got AADSTS53003.80c7d3f1(worked) and33339ed5(blocked). [CI] /review run-tests: report and retry Microsoft Entra sign-in failures #40485 only added retries and reporting.review-trigger.yml(the/reviewgate) uses the same identity and failed at 2026-11-22T02:04Z with the sameAADSTS53003(run 44974360023).203and a sign-in page from Azure DevOps. The real secret got401, which fits a token Azure DevOps recognizes but refuses under the same tenant policy./azp run.github-actions[bot]hasnonepermission on dotnet/maui, so the Azure Pipelines app would reject the comment. That app can't take the selected-category parameters anyway.Conclusion: No repository change can queue the targeted run while the tenant policy blocks every Azure DevOps credential from GitHub-hosted runners. A tenant admin has to exempt the trigger identity (
AZDO_TRIGGER_CLIENT_ID) from the Conditional Access policy, or approve the PAT. Once that's done, the existing flow works unchanged.What this PR fixes
AZDO_TRIGGER_PATis trimmed, so a pasted newline or space no longer breaks Basic auth.401, or203with its HTML sign-in page. Before, a203was read as a queued build. Both now count as a rejected PAT, and the run falls back to the federated identity. Timeouts and other errors still fail without a retry, so a build is never queued twice./review run-testsagain later", which can't work while the policy is in place. It now says to use/azp run maui-pr-uitestsfor the full suite, and that targeted runs return once sign-in works again. A plain401from the queue call gets the same message..github/docs/trigger-azdo-pipeline-setup.mdcoversAADSTS53003and the PAT failure modes.Validation
ghwrites so nothing was posted. Results:203./azp run maui-pr-uitestsguidance was written to the comment and warning.Invoke-Pester ./.github/scripts/RunTests.Tests.ps1passed 58, failed 0.Issues Fixed
Follow-up to #40492 (the PAT fallback didn't work) and #40485.