{"record":{"id":"43b4d5d526ce5520","repo":"Hmbown/CodeWhale","slug":"github-diff-exceeds-its-300-file-limit","errorCode":null,"errorMessage":"GitHub diff exceeds its 300-file limit","messagePattern":"GitHub diff exceeds its 300-file limit","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"crates/tui/src/tools/review_pr.rs","lineNumber":263,"sourceCode":"    Ok(())\n}\n\nfn diff_with(\n    number: u32,\n    repo: Option<&str>,\n    view: &GhPullRequest,\n    run: &mut impl FnMut(Program, &[String]) -> Result<String>,\n) -> Result<String> {\n    // GitHub's diff representation refuses PRs with more than 300 files.\n    // Preserve remote-only small-PR usage, but never rely on that limit for\n    // completeness: also check the metadata's changed-file count.\n    let remote = if view.changed_files <= 300 {\n        run(Program::Gh, &pr_args(\"diff\", number, repo)).and_then(|diff| {\n            complete_file_set(&diff, view)?;\n            Ok(diff)\n        })\n    } else {\n        Err(anyhow::anyhow!(\"GitHub diff exceeds its 300-file limit\"))\n    };\n    let diff = match remote {\n        Ok(diff) => diff,\n        Err(remote_error) => {\n            let local: Result<String> = (|| {\n                let shallow = run(\n                    Program::Git,\n                    &[\"rev-parse\".into(), \"--is-shallow-repository\".into()],\n                )?;\n                if shallow.trim() != \"false\" {\n                    bail!(\"A full Git history is required to establish the PR merge base\");\n                }\n                let base = run(\n                    Program::Git,\n                    &[\n                        \"merge-base\".into(),\n                        \"--all\".into(),\n                        view.base_sha.clone(),","sourceCodeStart":245,"sourceCodeEnd":281,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/tools/review_pr.rs#L245-L281","documentation":"`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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["No user fix needed: the tool automatically falls back to local pinned git patches — check that the fallback succeeded","If the fallback also fails, split the PR into smaller PRs under 300 files","Exclude generated files from the PR via .gitattributes or by splitting them out"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"let view = fetch_view(pr)?; if view.changed_files > 300 { plan_local_git_fallback(pr); }","typeGuard":null,"tryCatchPattern":"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) }","preventionTips":["Keep PRs under 300 changed files; split bulk refactors","Ignore generated files/lockfile noise via .gitattributes or PR hygiene","Ensure the local git checkout has the pinned commits so the fallback can run"],"tags":["github","pr","diff","limit","fallback"],"backgroundTag":"file-size-limit-exceeded","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-22T16:17:23.217Z"}