Hmbown/CodeWhale · warning

GitHub diff exceeds its 300-file limit

Error message

GitHub diff exceeds its 300-file limit

What it means

`diff_with` in the PR review tool first tries `gh pr diff`, but GitHub's diff endpoint silently truncates at 300 changed files. When the PR view reports more than 300 changed files, the tool refuses the remote diff up front and falls back to locally assembled pinned git patches, guaranteeing a complete file set.

Solutions

  1. No user fix needed: the tool automatically falls back to local pinned git patches — check that the fallback succeeded
  2. If the fallback also fails, split the PR into smaller PRs under 300 files
  3. Exclude generated files from the PR via .gitattributes or by splitting them out
Defensive patterns

Strategy: fallback

Validate before calling

let view = fetch_view(pr)?; if view.changed_files > 300 { plan_local_git_fallback(pr); }

Try / catch

match diff_with(pr) { Ok(diff) => diff, Err(e) if e.to_string().contains("300-file limit") => build_diff_from_pinned_git_patches(pr)?, Err(e) => return Err(e) }

Prevention

When it happens

Trigger: Calling `diff_with` for a PR whose `view.changed_files > 300`; the error is raised before/independent of any network call and triggers the local-git fallback path.

Common situations: Mass refactors, generated-code or lockfile-heavy PRs, automated bulk dependency updates that touch hundreds of files; CI-generated PRs exceeding GitHub's diff limit.

Understand the failure class

Background: "File too large" / "file size exceeds limit" errors: why libraries cap file sizes and how to fix them — this error's family across 46 libraries.

Related errors


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

Appendix: source

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

    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.
    let remote = if view.changed_files <= 300 {
        run(Program::Gh, &pr_args("diff", number, repo)).and_then(|diff| {
            complete_file_set(&diff, view)?;
            Ok(diff)
        })
    } else {
        Err(anyhow::anyhow!("GitHub diff exceeds its 300-file limit"))
    };
    let diff = match remote {
        Ok(diff) => diff,
        Err(remote_error) => {
            let local: Result<String> = (|| {
                let shallow = run(
                    Program::Git,
                    &["rev-parse".into(), "--is-shallow-repository".into()],
                )?;
                if shallow.trim() != "false" {
                    bail!("A full Git history is required to establish the PR merge base");
                }
                let base = run(
                    Program::Git,
                    &[
                        "merge-base".into(),
                        "--all".into(),
                        view.base_sha.clone(),

View on GitHub (pinned to 73e0f67d83)