Skip to content

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

@radical

Description

@radical

Bug

get-aspire-cli-pr.sh fails to install the Aspire CLI from a PR when the PR touches too many files.

Failure

The LegacySettingsMigration_AdjustsRelativeAppHostPath CLI E2E test failed in CI run #24410740249 on PR #15995 because the script could not retrieve the PR HEAD SHA.

Terminal recording: ▶️ View Recording

Root Cause

The get_pr_head_sha() function in eng/scripts/get-aspire-cli-pr.sh calls the single-PR REST endpoint:

GET /repos/microsoft/aspire/pulls/{pr_number}

This endpoint computes the full diff. When a PR has too many changed files, GitHub returns HTTP 422:

{"message":"The request could not be processed because too many files changed","documentation_url":"https://docs.github.com/rest/pulls/pulls#get-a-pull-request","status":"422"}

The script treats this as a fatal error and exits before downloading CLI artifacts.

Relevant code (eng/scripts/get-aspire-cli-pr.sh, line ~615):

head_sha=$(gh_api_call "${GH_REPOS_BASE}/pulls/$pr_number" ".head.sha" "Failed to get HEAD SHA for PR #$pr_number")

Suggested Fix

Use the GraphQL API to fetch just the head SHA without computing the diff:

gh api graphql \
  -f query='{ repository(owner:"microsoft",name:"aspire") { pullRequest(number:) { headRefOid } } }' \
  --jq '.data.repository.pullRequest.headRefOid'

Or alternatively, use the REST API with a media type that skips the diff, or query the git/ref endpoint using the PR branch name.

Affected Script

  • eng/scripts/get-aspire-cli-pr.shget_pr_head_sha() function (line ~609)
  • The same pattern may also exist in eng/scripts/get-aspire-cli-pr.ps1

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions