Skip to content

Use GraphQL PR head lookup in get-aspire-cli-pr scripts to avoid REST 422 on large PRs#16169

Merged
radical merged 6 commits intomainfrom
copilot/fix-get-aspire-cli-pr-failure
Apr 15, 2026
Merged

Use GraphQL PR head lookup in get-aspire-cli-pr scripts to avoid REST 422 on large PRs#16169
radical merged 6 commits intomainfrom
copilot/fix-get-aspire-cli-pr-failure

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 14, 2026

Description

get-aspire-cli-pr could fail before artifact download when GET /pulls/{number} returns HTTP 422 for large diffs. This change makes PR HEAD SHA resolution independent of diff generation by querying GraphQL headRefOid, with a REST fallback for environments where GraphQL is unavailable.

  • Scope

    • Updates eng/scripts/get-aspire-cli-pr.sh and eng/scripts/get-aspire-cli-pr.ps1 in get_pr_head_sha / Get-PRHeadSHA.
  • Behavior change

    • Primary path: GraphQL query for repository.pullRequest(number).headRefOid.
    • Fallback path: existing REST .head.sha lookup if GraphQL call fails.
    • Keeps existing failure semantics for invalid PR/access issues and validates owner/name repo format before querying.
  • Implementation sketch

    gh api graphql \
      -f query='query($owner:String!, $name:String!, $number:Int!) { repository(owner:$owner, name:$name) { pullRequest(number:$number) { headRefOid } } }' \
      -F owner="$repo_owner" -F name="$repo_name" -F number="$pr_number" \
      --jq '.data.repository.pullRequest.headRefOid'

Fixes #16168

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No
  • Does the change require an update in our Aspire docs?

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • 1s1vsblobprodcus386.vsblob.vsassets.io
    • Triggering command: /home/REDACTED/work/aspire/aspire/.dotnet/dotnet /home/REDACTED/work/aspire/aspire/.dotnet/dotnet /home/REDACTED/work/aspire/aspire/.dotnet/sdk/10.0.201/MSBuild.dll /noautoresponse /nologo /nodemode:1 /nodeReuse:true /low:false (dns block)
  • c78vsblobprodcus322.vsblob.vsassets.io
    • Triggering command: /home/REDACTED/work/aspire/aspire/.dotnet/dotnet /home/REDACTED/work/aspire/aspire/.dotnet/dotnet /home/REDACTED/work/aspire/aspire/.dotnet/sdk/10.0.201/MSBuild.dll /noautoresponse /nologo /nodemode:1 /nodeReuse:true /low:false (dns block)
  • https://api.github.com/graphql
    • Triggering command: /usr/bin/gh gh api graphql -f query=query($owner:String!, $name:String!, $number:Int!) { repository(owner:$owner, name:$name) { pullRequest(number:$number) { headRefOid } } } -F owner=microsoft -F name=aspire -F number=15995 --jq .data.repository.pullRequest.headRefOid aspire-cli-pr-failure --local cal/bin/bash user.name -deps.ps1 (http block)
    • Triggering command: /usr/bin/gh gh api graphql -f query=query($owner:String!, $name:String!, $number:Int!) { repository(owner:$owner, name:$name) { pullRequest(number:$number) { headRefOid } } } -F owner=microsoft -F name=aspire -F number=15995 --jq .data.repository.pullRequest.headRefOid celain --ignore-submodules | head -n 10 --local ateFailingTestIssue.csproj user.email (http block)
    • Triggering command: /usr/bin/gh gh api graphql -f query=query($owner:String!, $name:String!, $number:Int!) { repository(owner:$owner, name:$name) { pullRequest(number:$number) { headRefOid } } } -F owner=microsoft -F name=aspire -F number=15995 ools/linux_x64/p/home/REDACTED/work/aspire/aspire/tools/scripts/DownloadFailingJobLogs.cs d4b3�� dotnet&#34; global.json bash committer.email (http block)
  • https://api.github.com/repos/microsoft/aspire/pulls/100
    • Triggering command: /usr/bin/gh gh api repos/microsoft/aspire/pulls/100 --jq .head.sha --get-regexp --local artifacts/bin/replace-text/Debug/replace-text (http block)
  • kxqvsblobprodcus376.vsblob.vsassets.io
    • Triggering command: /home/REDACTED/work/aspire/aspire/.dotnet/dotnet /home/REDACTED/work/aspire/aspire/.dotnet/dotnet /home/REDACTED/work/aspire/aspire/.dotnet/sdk/10.0.201/MSBuild.dll /noautoresponse /nologo /nodemode:1 /nodeReuse:true /low:false (dns block)
  • l49vsblobprodcus358.vsblob.vsassets.io
    • Triggering command: /home/REDACTED/work/aspire/aspire/.dotnet/dotnet /home/REDACTED/work/aspire/aspire/.dotnet/dotnet /home/REDACTED/work/aspire/aspire/.dotnet/sdk/10.0.201/MSBuild.dll /noautoresponse /nologo /nodemode:1 /nodeReuse:true /low:false (dns block)
  • pkvvsblobprodcus321.vsblob.vsassets.io
    • Triggering command: /home/REDACTED/work/aspire/aspire/.dotnet/dotnet /home/REDACTED/work/aspire/aspire/.dotnet/dotnet /home/REDACTED/work/aspire/aspire/.dotnet/sdk/10.0.201/MSBuild.dll /noautoresponse /nologo /nodemode:1 /nodeReuse:true /low:false (dns block)
  • u3hvsblobprodcus371.vsblob.vsassets.io
    • Triggering command: /home/REDACTED/work/aspire/aspire/.dotnet/dotnet /home/REDACTED/work/aspire/aspire/.dotnet/dotnet /home/REDACTED/work/aspire/aspire/.dotnet/sdk/10.0.201/MSBuild.dll /noautoresponse /nologo /nodemode:1 /nodeReuse:true /low:false (dns block)
  • uy6vsblobprodcus34.vsblob.vsassets.io
    • Triggering command: /usr/share/dotnet/dotnet dotnet test tests/Infrastructure.Tests/Infrastructure.Tests.csproj -tl:off -- --filter-not-trait quarantined=true --filter-not-trait outerloop=true (dns block)
    • Triggering command: /usr/share/dotnet/dotnet dotnet build /home/REDACTED/work/aspire/aspire/tools/GenerateTestSummary/GenerateTestSummary.csproj --restore (dns block)
    • Triggering command: /usr/share/dotnet/dotnet dotnet build /home/REDACTED/work/aspire/aspire/tools/ExtractTestPartitions/ExtractTestPartitions.csproj --restore (dns block)
  • v53vsblobprodcus320.vsblob.vsassets.io
    • Triggering command: /home/REDACTED/work/aspire/aspire/.dotnet/dotnet /home/REDACTED/work/aspire/aspire/.dotnet/dotnet /home/REDACTED/work/aspire/aspire/.dotnet/sdk/10.0.201/MSBuild.dll /noautoresponse /nologo /nodemode:1 /nodeReuse:true /low:false (dns block)
  • yluvsblobprodcus367.vsblob.vsassets.io
    • Triggering command: /home/REDACTED/work/aspire/aspire/.dotnet/dotnet /home/REDACTED/work/aspire/aspire/.dotnet/dotnet /home/REDACTED/work/aspire/aspire/.dotnet/sdk/10.0.201/MSBuild.dll /noautoresponse /nologo /nodemode:1 /nodeReuse:true /low:false (dns block)
  • ytvvsblobprodcus310.vsblob.vsassets.io
    • Triggering command: /home/REDACTED/work/aspire/aspire/.dotnet/dotnet /home/REDACTED/work/aspire/aspire/.dotnet/dotnet /home/REDACTED/work/aspire/aspire/.dotnet/sdk/10.0.201/MSBuild.dll /noautoresponse /nologo /nodemode:1 /nodeReuse:true /low:false (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title [WIP] Fix HTTP 422 error in get-aspire-cli-pr.sh for large PRs Use GraphQL PR head lookup in get-aspire-cli-pr scripts to avoid REST 422 on large PRs Apr 14, 2026
Copilot AI requested a review from radical April 14, 2026 20:09
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 14, 2026

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 16169

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 16169"

@radical radical marked this pull request as ready for review April 14, 2026 20:53
Copilot AI review requested due to automatic review settings April 14, 2026 20:53
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Updates get-aspire-cli-pr scripts to resolve PR HEAD SHA via GitHub GraphQL (headRefOid) to avoid REST GET /pulls/{number} returning HTTP 422 on large diffs, with a REST fallback when GraphQL is unavailable.

Changes:

  • Add owner/name repository format validation before PR lookup.
  • Prefer GraphQL repository.pullRequest(number).headRefOid for HEAD SHA resolution.
  • Fall back to existing REST .head.sha lookup when the GraphQL call fails.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
eng/scripts/get-aspire-cli-pr.sh Adds GraphQL-based PR head SHA lookup with REST fallback and repo format validation.
eng/scripts/get-aspire-cli-pr.ps1 Mirrors the GraphQL-first PR head SHA lookup and fallback behavior in PowerShell.

Comment thread eng/scripts/get-aspire-cli-pr.sh
Comment thread eng/scripts/get-aspire-cli-pr.ps1 Outdated
- Use anchored regex in bash to match PowerShell repo format validation
- Change -F to -f for owner/name GraphQL vars to prevent numeric type coercion

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Bash: redirect stderr to /dev/null, check stdout for valid SHA
- PowerShell: capture stdout only (2>$null), normalize to trimmed string
- Both: treat null/empty GraphQL result as failure triggering REST fallback

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Member

@JamesNK JamesNK left a comment

Choose a reason for hiding this comment

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

Clean change. GraphQL query is well-formed with parameterized variables, stderr is correctly separated from stdout on both platforms, PowerShell output is normalized, and the REST fallback preserves the original error semantics. No issues found.

@radical radical enabled auto-merge (squash) April 15, 2026 02:40
@radical radical merged commit f76f55b into main Apr 15, 2026
278 checks passed
@github-actions github-actions bot added this to the 13.3 milestone Apr 15, 2026
@github-actions
Copy link
Copy Markdown
Contributor

🎬 CLI E2E Test Recordings — 69 recordings uploaded (commit eb76766)

View recordings
Test Recording
AddPackageInteractiveWhileAppHostRunningDetached ▶️ View Recording
AddPackageWhileAppHostRunningDetached ▶️ View Recording
AgentCommands_AllHelpOutputs_AreCorrect ▶️ View Recording
AgentInitCommand_DefaultSelection_InstallsSkillOnly ▶️ View Recording
AgentInitCommand_MigratesDeprecatedConfig ▶️ View Recording
AspireAddPackageVersionToDirectoryPackagesProps ▶️ View Recording
AspireUpdateRemovesAppHostPackageVersionFromDirectoryPackagesProps ▶️ View Recording
Banner_DisplayedOnFirstRun ▶️ View Recording
Banner_DisplayedWithExplicitFlag ▶️ View Recording
Banner_NotDisplayedWithNoLogoFlag ▶️ View Recording
CertificatesClean_RemovesCertificates ▶️ View Recording
CertificatesTrust_WithNoCert_CreatesAndTrustsCertificate ▶️ View Recording
CertificatesTrust_WithUntrustedCert_TrustsCertificate ▶️ View Recording
ConfigSetGet_CreatesNestedJsonFormat ▶️ View Recording
CreateAndRunAspireStarterProject ▶️ View Recording
CreateAndRunAspireStarterProjectWithBundle ▶️ View Recording
CreateAndRunEmptyAppHostProject ▶️ View Recording
CreateAndRunJavaEmptyAppHostProject ▶️ View Recording
CreateAndRunJsReactProject ▶️ View Recording
CreateAndRunPythonReactProject ▶️ View Recording
CreateAndRunTypeScriptEmptyAppHostProject ▶️ View Recording
CreateAndRunTypeScriptStarterProject ▶️ View Recording
CreateJavaAppHostWithViteApp ▶️ View Recording
CreateTypeScriptAppHostWithViteApp ▶️ View Recording
DashboardRunWithOtelTracesReturnsNoTraces ▶️ View Recording
DeployK8sBasicApiService ▶️ View Recording
DeployK8sWithGarnet ▶️ View Recording
DeployK8sWithMongoDB ▶️ View Recording
DeployK8sWithMySql ▶️ View Recording
DeployK8sWithPostgres ▶️ View Recording
DeployK8sWithRabbitMQ ▶️ View Recording
DeployK8sWithRedis ▶️ View Recording
DeployK8sWithSqlServer ▶️ View Recording
DeployK8sWithValkey ▶️ View Recording
DeployTypeScriptAppToKubernetes ▶️ View Recording
DescribeCommandResolvesReplicaNames ▶️ View Recording
DescribeCommandShowsRunningResources ▶️ View Recording
DetachFormatJsonProducesValidJson ▶️ View Recording
DoListStepsShowsPipelineSteps ▶️ View Recording
DoctorCommand_DetectsDeprecatedAgentConfig ▶️ View Recording
DoctorCommand_WithSslCertDir_ShowsTrusted ▶️ View Recording
DoctorCommand_WithoutSslCertDir_ShowsPartiallyTrusted ▶️ View Recording
GlobalMigration_HandlesCommentsAndTrailingCommas ▶️ View Recording
GlobalMigration_HandlesMalformedLegacyJson ▶️ View Recording
GlobalMigration_PreservesAllValueTypes ▶️ View Recording
GlobalMigration_SkipsWhenNewConfigExists ▶️ View Recording
GlobalSettings_MigratedFromLegacyFormat ▶️ View Recording
InitTypeScriptAppHost_AugmentsExistingViteRepoAtRoot ▶️ View Recording
InvalidAppHostPathWithComments_IsHealedOnRun ▶️ View Recording
LegacySettingsMigration_AdjustsRelativeAppHostPath ▶️ View Recording
LogsCommandShowsResourceLogs ▶️ View Recording
OtelLogsReturnsStructuredLogsFromStarterApp ▶️ View Recording
PsCommandListsRunningAppHost ▶️ View Recording
PsFormatJsonOutputsOnlyJsonToStdout ▶️ View Recording
PublishWithConfigureEnvFileUpdatesEnvOutput ▶️ View Recording
PublishWithDockerComposeServiceCallbackSucceeds ▶️ View Recording
RestoreGeneratesSdkFiles ▶️ View Recording
RestoreSupportsConfigOnlyHelperPackageAndCrossPackageTypes ▶️ View Recording
RunFromParentDirectory_UsesExistingConfigNearAppHost ▶️ View Recording
SecretCrudOnDotNetAppHost ▶️ View Recording
SecretCrudOnTypeScriptAppHost ▶️ View Recording
StagingChannel_ConfigureAndVerifySettings_ThenSwitchChannels ▶️ View Recording
StartAndWaitForTypeScriptSqlServerAppHostWithNativeAssets ▶️ View Recording
StopAllAppHostsFromAppHostDirectory ▶️ View Recording
StopAllAppHostsFromUnrelatedDirectory ▶️ View Recording
StopNonInteractiveMultipleAppHostsShowsError ▶️ View Recording
StopNonInteractiveSingleAppHost ▶️ View Recording
StopWithNoRunningAppHostExitsSuccessfully ▶️ View Recording
UnAwaitedChainsCompileWithAutoResolvePromises ▶️ View Recording

📹 Recordings uploaded automatically from CI run #24438033504

@aspire-repo-bot
Copy link
Copy Markdown
Contributor

No documentation PR is required for this change.

This PR updates internal CI scripts (eng/scripts/get-aspire-cli-pr.sh and eng/scripts/get-aspire-cli-pr.ps1) to use GraphQL for PR HEAD SHA resolution instead of the REST API. It's a build/CI infrastructure fix with no user-facing behavior, public API, or configuration changes.

Generated by PR Documentation Check for issue #16169 · ● 147.6K ·

@radical radical deleted the copilot/fix-get-aspire-cli-pr-failure branch April 15, 2026 17:59
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.

get-aspire-cli-pr.sh fails with HTTP 422 when PR has too many changed files

5 participants