fix: reconstruct diff from per-file patches when GitHub 406s on large PRs - #61
Open
jainakshay93 wants to merge 1 commit into
Open
fix: reconstruct diff from per-file patches when GitHub 406s on large PRs#61jainakshay93 wants to merge 1 commit into
jainakshay93 wants to merge 1 commit into
Conversation
… PRs _fetch_pr_once fetches the diff via the .diff media type, which GitHub 406s when the diff is too large (e.g. 722-file PR), aborting the review. On 406, rebuild the unified diff from the per-file patches already fetched from the /files API. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
_fetch_pr_oncefetches the PR diff viaAccept: application/vnd.github.v3.diff. GitHub returns 406 Not Acceptable when the diff is too large to generate — reproduced on a 722-file PR.diff_resp.raise_for_status()then aborts the whole review, so large PRs can't be reviewed at all.Fix
The per-file patches are already fetched from the
/pulls/{n}/filesAPI a few lines above. On a 406, reconstruct an equivalent unified diff from those patches instead of failing:Small/normal PRs are unchanged — the real
.diffmedia type is still used whenever it succeeds.Testing
A 722-file PR that previously 406'd now fetches (≈3.5 MB reconstructed diff) and reviews to completion.
Note
GitHub's
/filesAPI caps at 3000 files and omitspatchfor individually huge files, so extreme PRs may have partial diffs — but a partial diff is strictly better than a hard failure.🤖 Generated with Claude Code