Skip to content

consult --type pr cannot review a PR over GitHub's 20,000-line diff cap, and exits 0 when it refuses #267

Description

@pseudoseed

What happens

consult -m <lane> --type pr on PR #266 (~43,700 diff lines, 130 files):

[forge] 'pr-diff' (sync) exited 1 — reporting NO RESULTS, which is not the same as none.
        could not find pull request diff: HTTP 406: Sorry, the diff exceeded the maximum
        number of lines (20000) (https://api.github.com/repos/pseudoseed/codev/pulls/266)
PR #266 produced a 0-byte diff — refusing to run a review on nothing.

Both lanes refused. No review is possible on a PR this size via --type pr.

Two separate defects

1. The refusal exits 0. Both lanes printed the refusal and returned exit code 0, so a caller
that checks the exit status — porch does — sees a successful consultation with no output file
written. The refusal message itself is well-judged and says exactly the right thing ("a reviewer
cannot tell an empty diff from a failed fetch"), and then the exit code spells that refusal the
same way it spells success. A refusal should exit non-zero.

2. pr-diff has no fallback for the API's line cap. The forge concept is
gh pr diff "$CODEV_PR_NUMBER", which goes through GitHub's .diff media type and is hard-capped
at 20,000 lines. The cap is on the API, not on the content: the identical diff is available from
git as git diff <base>...<head> with no cap at all, and consult already writes the diff to a temp
file for the model to read rather than inlining it, so size is not the constraint anywhere else in
the path.

Why the cap will keep being hit

Nothing about #266 is pathological — it is one spec's worth of work at 11 phases. Any project that
vendors generated artifacts, adds screenshots, or lands a large fixture set clears 20,000 lines
easily.

Suggested fix

In the pr-diff GitHub forge script, fall back to git when gh pr diff fails, using the PR's own
base and head from gh pr view --json baseRefName,headRefName:

gh pr diff "$CODEV_PR_NUMBER" 2>/dev/null && exit 0
# API caps the .diff media type at 20,000 lines; git has no such cap and the
# three-dot diff from the merge-base is what GitHub renders.
eval "$(gh pr view "$CODEV_PR_NUMBER" --json baseRefName,headRefName \
  --jq '"BASE=\(.baseRefName) HEAD=\(.headRefName)"')"
exec git diff "origin/$BASE...$HEAD"

Verified equivalent on #266: the git three-dot diff reports the same 130 changed files that
gh pr view --json changedFiles reports.

Workaround used

A local gh shim on PATH for the one invocation, intercepting pr diff only and passing
everything else through. Not committed; .codev/config.json was deliberately not edited because it
is a symlink to the shared workspace config and every builder reads it.

Found by

Spec 250, review phase. PR #266.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/consultMulti-agent consultation CLI

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions