Hmbown/CodeWhale · error · anyhow::Error
Complete local diff requires
Error message
Complete local diff requires {chars} characters, exceeding the review limit of {max_chars}. No review was run and no receipt was written or accepted. Select an explicit --path scope, or increase --max-chars only if the selected model can accept the complete input. What it means
Before sending a complete local diff for review, the code counts its characters and refuses to proceed if it exceeds the configured --max-chars limit. This is a deliberate guard: no model request is made and no review receipt is written or accepted when the diff is truncated implicitly.
Solutions
- Narrow the review with an explicit `--path <scope>` so only relevant files are diffed
- Increase `--max-chars` only if the selected model's context window can accept the complete input
- Reduce the diff itself: split the change, or exclude generated/vendored files from the review scope
Example fix
// before codewhale review # 900k-char diff vs 200k limit // after codewhale review --path crates/tui --max-chars 200000
Defensive patterns
Strategy: validation
Validate before calling
let chars: usize = git_diff.chars().count();
if chars > max_chars { /* narrow with --path or raise max_chars before invoking review */ } Prevention
- Always scope reviews with --path on large working trees
- Check diff size (`git diff | wc -m`) before running the review
- Raise --max-chars only after confirming the model's context window
When it happens
Trigger: `ensure_local_review_diff_fits` finds `diff.chars().count() > max_chars` — the full working-tree diff (no --path scope) is larger than the review character budget.
Common situations: Reviewing a big refactor or vendored-code drop with the default limit; diffing binary-ish or generated files that inflate the diff; running against a monorepo without narrowing scope.
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
- GitHub diff exceeds its 300-file limit
- Input exceeds 64 MiB.
- --max-passes applies only to --pr reviews
- ; publication: ; completed review passes: / ; accumulated…
- No diff to review.
AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22).
Data as JSON: /api/errors/f105cd1262c382ac.
Report an issue: GitHub.
Appendix: source
Thrown at crates/tui/src/lib.rs:9871
let output = cmd
.output()
.map_err(|e| anyhow::anyhow!("Failed to run git diff. Is git installed? ({e})"))?;
if !output.status.success() {
let stderr = String::from_utf8_lossy(&output.stderr);
bail!("git diff failed: {}", stderr.trim());
}
String::from_utf8_lossy(&output.stdout).to_string()
};
if args.pr.is_none() {
ensure_local_review_diff_fits(&diff, args.max_chars)?;
}
Ok(diff)
}
fn ensure_local_review_diff_fits(diff: &str, max_chars: usize) -> Result<()> {
let chars = diff.chars().count();
if chars > max_chars {
bail!(
"Complete local diff requires {chars} characters, exceeding the review limit of {max_chars}. No review was run and no receipt was written or accepted. Select an explicit --path scope, or increase --max-chars only if the selected model can accept the complete input."
);
}
Ok(())
}
fn review_target_label(args: &ReviewArgs) -> String {
let mut label = if let Some(number) = args.pr {
format!("pr:{number}")
} else if args.staged {
"staged".to_string()
} else if let Some(base) = args
.base
.as_deref()
.map(str::trim)
.filter(|base| !base.is_empty())
{
format!("base:{base}")View on GitHub (pinned to 73e0f67d83)