Skip to content

sweep: stop retrying diffs GitHub refuses to serve - #49

Merged
Octember merged 1 commit into
mainfrom
claude/stupify-down-6daf97
Jul 25, 2026
Merged

sweep: stop retrying diffs GitHub refuses to serve#49
Octember merged 1 commit into
mainfrom
claude/stupify-down-6daf97

Conversation

@Octember

Copy link
Copy Markdown
Owner

The bug

gh pr diff returns HTTP 406 on any diff past 20,000 lines:

could not find pull request diff: HTTP 406: Sorry, the diff exceeded the maximum number of lines (20000)
PullRequest.diff too_large

getDiff mapped every non-zero exit to null, so the sweep logged "couldn't read its diff from gh; will retry next sweep" and the 60s cron re-fetched forever. 11,055 wasted attempts on the bevyl VM, across #8338 / #8308 / #8241 / #8121 — and the message promised a retry that could never succeed.

Raising DIFF_LINE_CAP 5k → 20k in dd27ec5 is what made this reachable: GitHub's own diff limit is exactly 20000, so the cap can never be hit. Anything that 406s is already over cap by definition.

The fix

getDiff now returns a discriminated result instead of string | null:

type DiffRead = { ok: true; diff: string } | { ok: false; reason: 'unreadable' | 'too-large' }
  • unreadable — unchanged, still transient, still retried.
  • too-large — terminal. Skipped for good, with a message that says what actually happened:
skip #8121 — diff over GitHub's 20000-line API limit — gh can't return it,
so it can't be reviewed; split the PR

The manual stupify review <N> path had the same bug (it only said "couldn't fetch the diff") and gets the same treatment.

Notes for the reviewer

  • Commit status stays success, matching the existing over-cap skip. GitHub statuses have no neutral state, and error would permanently red-X every oversized PR and block merges on ones we simply cannot read.
  • isDiffTooLarge is exported as a testable predicate, following the existing isRateLimited pattern.
  • The test uses the real 406 text; the classifier was also verified against live output captured from bevyl #8121.

This stops the retry loop and the misleading message. It does not make those 4 PRs reviewable — GitHub will not serve a >20k-line diff to anyone.

`gh pr diff` 406s on anything past 20k lines, and `getDiff` mapped every
non-zero exit to null — so the sweep logged "will retry next sweep" and
re-fetched those PRs every 60s forever. 11,055 wasted attempts on bevyl,
across #8338/#8308/#8241/#8121.

Raising DIFF_LINE_CAP 5k -> 20k in dd27ec5 made this reachable: GitHub's
own limit is exactly 20000, so the cap can never be hit — anything that
406s is already unreviewable.

Split the two failure modes. 'unreadable' still retries; 'too-large' is
terminal and now says so, on the sweep path and on `stupify review <N>`
(which had the same bug).

Commit status stays success, matching the existing over-cap skip: there
is no neutral status, and a red X would block merges on PRs we simply
cannot read.

@exe-dev-github-integration exe-dev-github-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM ✅

@Octember
Octember merged commit bbb5fbf into main Jul 25, 2026
2 checks passed
@Octember
Octember deleted the claude/stupify-down-6daf97 branch July 25, 2026 12:59
Octember added a commit that referenced this pull request Jul 25, 2026
#49 only matched "diff exceeded the maximum number of lines". GitHub
406s on TWO limits — 20000 lines and 300 files — so #8338 and #8241
(both over the file cap) stayed in the retry loop after the fix, while
#8308 and #8121 correctly dropped out.

Match gh's stable `PullRequest.diff too_large` code, which both variants
carry, and keep the prose patterns as a fallback. Both real payloads are
pinned in the test.
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.

1 participant