Skip to content

fix(design-decision-gate): handle >300-file PRs without HTTP 406 abort#40078

Merged
pelikhan merged 4 commits into
mainfrom
copilot/aw-failures-tolerate-large-prs
Jun 18, 2026
Merged

fix(design-decision-gate): handle >300-file PRs without HTTP 406 abort#40078
pelikhan merged 4 commits into
mainfrom
copilot/aw-failures-tolerate-large-prs

Conversation

Copilot AI commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

The Pre-fetch ADR gate PR context step called gh pr diff unconditionally. For PRs with >300 changed files the GitHub diff API returns HTTP 406, and set -euo pipefail killed the step before the agent could run.

Changes

  • Fetch orderpr-files.json (paginated) is now fetched before gh pr diff so the file count is known before attempting the diff call.
  • File-count guard — When FILE_COUNT > 300, the diff call is skipped entirely; a descriptive notice is written to pr.diff and a ::warning:: annotation is emitted instead of exiting 1.
  • Extended summaryadr-prefetch-summary.json gains two new fields:
    • file_count — total changed files
    • diff_available — boolean (computed via jq -n to avoid shell edge cases)
  • Agent prompt — Fallback instruction for pr.diff now branches on diff_available: when false, directs the agent to use pr-files.json for file-level analysis and explicitly suppresses the mcp__github__get_pull_request_diff call (which would also 406).
  • .gitattributes — Replaced the two path-specific *.lock.yml entries with a single *.lock.yml linguist-generated=true merge=ours pattern so all .lock.yml files anywhere in the repository are collapsed by default in GitHub PR diffs.
FILE_COUNT=$(jq 'length' /tmp/gh-aw/agent/pr-files.json)

if [ "$FILE_COUNT" -gt 300 ]; then
  echo "::warning::PR has $FILE_COUNT changed files (exceeds the 300-file GitHub diff API limit). Skipping full diff; file listing is available in pr-files.json."
  printf '# Diff unavailable: PR has %s changed files ...\n' "$FILE_COUNT" \
    > /tmp/gh-aw/agent/pr.diff
else
  gh pr diff "$PR_NUMBER" --repo "$EXPR_GITHUB_REPOSITORY" > /tmp/gh-aw/agent/pr.diff
fi

Copilot AI and others added 2 commits June 18, 2026 14:30
…ch step

- Fetch pr-files.json before attempting gh pr diff so file count is
  known before the diff call that can 406.
- Add a FILE_COUNT guard: when >300 files, write a warning notice to
  pr.diff and emit a ::warning:: annotation instead of calling the
  GitHub diff API (which returns HTTP 406 for >300-file PRs).
- Add file_count and diff_available fields to adr-prefetch-summary.json
  so the agent knows when the diff was skipped.
- Update agent prompt to use pr-files.json (not mcp diff API) when
  diff_available is false.

Fixes: large-PR HTTP 406 causing step exit-1 before agent runs.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
… cases

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix pre-fetch ADR gate to tolerate large PRs fix(design-decision-gate): handle >300-file PRs without HTTP 406 abort Jun 18, 2026
Copilot AI requested a review from pelikhan June 18, 2026 14:32
@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot diff should ignore **/*.lock.yml files

….yml from PR diffs

Replace the two path-specific lock.yml entries with a single
`*.lock.yml linguist-generated=true merge=ours` pattern that covers
all *.lock.yml files anywhere in the repository.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>

Copilot AI commented Jun 18, 2026

Copy link
Copy Markdown
Contributor Author

@copilot diff should ignore **/*.lock.yml files

Done in 3db1be8. Replaced the two path-specific entries (.github/workflows/*.lock.yml and pkg/cli/workflows/*.lock.yml) with a single *.lock.yml linguist-generated=true merge=ours line that covers all .lock.yml files anywhere in the repository.

@pelikhan pelikhan marked this pull request as ready for review June 18, 2026 14:46
Copilot AI review requested due to automatic review settings June 18, 2026 14:46
@pelikhan pelikhan merged commit 2ed7197 into main Jun 18, 2026
@pelikhan pelikhan deleted the copilot/aw-failures-tolerate-large-prs branch June 18, 2026 14:46
Copilot stopped reviewing on behalf of pelikhan due to an error June 18, 2026 14:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 the design decision gate workflow to gracefully handle PRs with very large file counts by avoiding diff retrieval when it would exceed GitHub’s diff limitations.

Changes:

  • Skip fetching the full PR diff when the PR changes more than 300 files; emit a notice file instead.
  • Add file_count and diff_available to the prefetch summary JSON to guide downstream behavior.
  • Broaden .gitattributes rules for *.lock.yml and adjust workflow lockfile handling.
Show a summary per file
File Description
.github/workflows/design-decision-gate.md Adds file-count check, conditional diff fetch, and propagates file_count/diff_available into the summary + instructions.
.github/workflows/design-decision-gate.lock.yml Regenerates the locked workflow with the new prefetch logic and summary fields.
.gitattributes Broadens *.lock.yml handling and adds an extra workflow lockfile rule.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 3/3 changed files
  • Comments generated: 3

Comment on lines 120 to +122
--arg threshold "100" \
--argjson file_count "$FILE_COUNT" \
--argjson diff_available "$(jq -n --argjson fc "$FILE_COUNT" 'if $fc <= 300 then true else false end')" \
Comment thread .gitattributes
@@ -1,8 +1,7 @@
.changeset/*.md linguist-generated=true merge=ours
.github/workflows/*.lock.yml linguist-generated=true merge=ours
*.lock.yml linguist-generated=true merge=ours
Comment thread .gitattributes
slides/*.pptx filter=lfs diff=lfs merge=lfs -text
docs/slides/** filter=lfs diff=lfs merge=lfs -text

.github/workflows/*.lock.yml linguist-generated=true merge=ours No newline at end of file
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.

3 participants