Hmbown/CodeWhale · error

Complete PR file patch

Error message

Complete PR file patch {} requires {patch_chars} characters, exceeding the per-pass review limit of {max_chars}. No review was run or posted.

What it means

When splitting a file patch into passes, plan_pr_review guarantees each pass is self-contained. This ensure! fires when a single hunk plus its file header exceeds the entire per-pass max_chars budget, meaning no split at complete-hunk boundaries can ever fit that file. The review aborts entirely and posts nothing rather than reviewing a partial file.

Solutions

  1. Increase max_chars so the largest hunk plus header fits within one pass
  2. Exclude the oversized file from review (e.g. .gitattributes or review ignore config) or split it in the PR
  3. Regenerate/refactor the file so hunks are smaller (avoid single-giant-hunk generated files)

Example fix

// before
plan_pr_review(diff, view, 8_000, passes)? // hunk of 12k chars fails
// after
plan_pr_review(diff, view, 16_000, passes)? // largest hunk + header fits
Defensive patterns

Strategy: validation

Validate before calling

let fits = |patch: &str, max: usize| {
    let (header, hunks) = split_patch(patch);
    hunks.iter().all(|h| header.chars().count() + h.chars().count() <= max)
};

Try / catch

match plan_pr_review(...) { Err(e) if e.to_string().contains("exceeding the per-pass review limit") => raise_budget_or_exclude_file(e), other => other }

Prevention

When it happens

Trigger: A single file in the PR contains one enormous hunk (a generated file, minified bundle, lockfile, or data file) whose hunk plus header exceeds max_chars while planning the review.

Common situations: Reviewing PRs that touch vendored dependencies, JSON snapshots, or generated code; max_chars configured too small for large-hunk repos; a new binary-ish text file added to the PR.

Understand the failure class

Background: payload too large / request exceeds maximum size: why libraries cap bytes and how to fix oversize payloads — this error's family across 50 libraries.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@433685b202 (2026-09-15). Data as JSON: /api/errors/e540eaf958d38482. Report an issue: GitHub.

Appendix: source

Thrown at crates/tui/src/tools/review.rs:338

    // replayed into every part so each part stays a self-describing patch;
    // no line is elided, shortened or reordered. Sizes use the model
    // representation, so a binary payload already omitted there can never
    // drive a split.
    let mut pieces: Vec<PrReviewPiece<'_>> = Vec::new();
    for patch in patches {
        let patch_chars = super::review_pr::model_diff(patch).chars().count();
        if patch_chars <= max_chars {
            pieces.push(PrReviewPiece {
                diff: Cow::Borrowed(patch),
                label: patch_label(patch),
                header_bytes: 0,
            });
            continue;
        }
        let (header, hunks) = pr_file_hunks(patch);
        let header_chars = header.chars().count();
        let largest_hunk_chars = hunks.iter().map(|hunk| hunk.chars().count()).max();
        anyhow::ensure!(
            largest_hunk_chars.is_some_and(|hunk_chars| header_chars + hunk_chars <= max_chars),
            "Complete PR file patch {} requires {patch_chars} characters, exceeding the per-pass review limit of {max_chars}. No review was run or posted.",
            patch_label(patch)
        );
        let label = patch_label(patch);
        let mut parts: Vec<String> = Vec::new();
        let mut part = String::from(header);
        let mut part_chars = header_chars;
        for hunk in hunks {
            let hunk_chars = hunk.chars().count();
            if part_chars > header_chars && part_chars + hunk_chars > max_chars {
                parts.push(std::mem::replace(&mut part, String::from(header)));
                part_chars = header_chars;
            }
            part.push_str(hunk);
            part_chars += hunk_chars;
        }
        parts.push(part);

View on GitHub (pinned to 433685b202)