Surface partial coverage in byte-safe PR diff fetch#97
Merged
Conversation
… cap The incremental compare diff was read under subprocess text=True, which strict-UTF-8-decodes the entire gh api response. On large vendor-refresh PRs the diff inlines a non-UTF-8 byte (git misclassifies a NUL-free encrypted vendored file as text), so the decode raises UnicodeDecodeError and the whole pr-review job dies before the review step. The diff is also pathologically large in those cases (100s of MB), so even a clean decode would hand an unusable artifact to the reviewer. Read the diff as raw bytes via a new gh_api_bytes() helper, split it into per-file diff --git sections, drop vendored and known generated/lockfile sections, cap the retained diff at 20 MB with an explicit truncation marker, and decode the remainder with errors="backslashreplace" (lossless and never raises). When nothing reviewable remains, return None so the existing full-review fallback engages.
johnallers
approved these changes
Jun 15, 2026
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.
Why
The PR review context fetcher previously strict-decoded GitHub compare diffs, so a non-UTF-8 byte in a large vendor refresh could crash the required review job before the reviewer ran. Large compare diffs also need bounded review context, but filtering must not silently hide build-relevant paths from the reviewer.
What this changes
This keeps the byte-safe diff fetch, filters bulky vendored/generated/lockfile sections from the incremental artifact, and records partial-coverage metadata in
pr-context.json. The incremental artifact now includes a visible notice when sections were dropped or truncated,go.modandgo.sumstay reviewable, and marker-only truncation falls back to full review mode.The path parser now considers both sides of rename/copy sections so files moving between excluded and normal paths are retained for review. The review prompt also tells the reviewer to account for partial coverage before giving a no-blocking-issues verdict.
Validation:
python3 -m unittest discover -s .github/actions/pr-review/scripts -p 'test_*.py'