Hmbown/CodeWhale · error

Incomplete PR diff: received

Error message

Incomplete PR diff: received {files} file patches, {additions} additions and {deletions} deletions; expected {}, {} and {}. No partial review is accepted.

What it means

The final integrity check of complete_file_set: the parsed diff must contain at least one patch, exactly view.changed_files file patches, and line counts that exactly equal the PR metadata's additions and deletions. Any mismatch means the tool received a partial or stale diff, and no partial review is ever accepted.

Solutions

  1. Re-run the review end to end so view metadata and git diff come from the same pinned base/head SHAs
  2. Verify head/base SHAs still match: `gh pr view <n> --json baseRefOid,headRefOid,changedFiles,additions,deletions` vs the local `git diff --numstat` totals
  3. Ensure the local merge-base equals GitHub's base (full clone, up-to-date origin fetch) so the diff covers the same commits
Defensive patterns

Strategy: validation

Validate before calling

// compare local diff tallies with PR metadata first
let numstat = git_numstat(base, head)?;
let (files, add, del) = (numstat.len(), add_total, del_total);
assert_eq!(files, view.changed_files, "file count mismatch");
assert_eq!(add, view.additions, "additions mismatch");
assert_eq!(del, view.deletions, "deletions mismatch");

Try / catch

match diff_with(&view) {
    Err(e) if e.to_string().contains("No partial review is accepted") => eprintln!("snapshot and diff out of sync; rerun review so both use the same pinned SHAs"),
    other => other?,
}

Prevention

When it happens

Trigger: diff_with collected git patches whose file/addition/deletion tallies disagree with the GhPullRequest metadata (changed_files, additions, deletions) captured by fetch_view — e.g. the diff was truncated, the PR moved between the two fetches, or counts were misparsed.

Common situations: PR force-pushed between view and diff fetch (counts mismatch); output truncation dropping the last files of a large diff; line-ending or whitespace flags changing countable added/removed lines vs GitHub's accounting; merge-base drift so the local diff covers different commits than GitHub reports.

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22). Data as JSON: /api/errors/e12577854397a0b3. Report an issue: GitHub.

Appendix: source

Thrown at crates/tui/src/tools/review_pr.rs:238

        {
            has_patch = true;
        } else if line.starts_with("Binary files ") {
            if !has_full_index {
                bail!(
                    "PR diff contains binary metadata without exact full object IDs; complete local Git objects are required"
                );
            }
            has_patch = true;
        }
    }
    if remaining != (0, 0)
        || !has_patch
        || files == 0
        || files != view.changed_files
        || additions != view.additions
        || deletions != view.deletions
    {
        bail!(
            "Incomplete PR diff: received {files} file patches, {additions} additions and {deletions} deletions; expected {}, {} and {}. No partial review is accepted.",
            view.changed_files,
            view.additions,
            view.deletions
        );
    }
    Ok(())
}

fn diff_with(
    number: u32,
    repo: Option<&str>,
    view: &GhPullRequest,
    run: &mut impl FnMut(Program, &[String]) -> Result<String>,
) -> Result<String> {
    // GitHub's diff representation refuses PRs with more than 300 files.
    // Preserve remote-only small-PR usage, but never rely on that limit for
    // completeness: also check the metadata's changed-file count.

View on GitHub (pinned to 73e0f67d83)