{"record":{"id":"e4eb264e6ed922c5","repo":"gitbutlerapp/gitbutler","slug":"cannot-comment-on-scope-the-diff-is-binary-or-t","errorCode":null,"errorMessage":"Cannot comment on {scope}: the diff is binary or too large","messagePattern":"Cannot comment on (.+?): the diff is binary or too large","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"warning","filePath":"crates/but-comments/src/lib.rs","lineNumber":140,"sourceCode":"    workspace: &but_graph::Workspace,\n    store: &CommentStore,\n    comment: NewComment,\n    context_lines: u32,\n    now_ms: i64,\n) -> anyhow::Result<DiffComment> {\n    let scope = anchor_scope_display(&comment.commit_change_id, &comment.path);\n    let mut diffs = ScopeDiffs::new(repo, workspace, context_lines);\n    let Some(anchor) = diffs.file(comment.commit_change_id.as_deref(), &comment.path)? else {\n        bail!(\n            \"Commit {} is not in the applied workspace\",\n            comment.commit_change_id.as_deref().unwrap_or_default()\n        );\n    };\n    let file = match anchor {\n        FileAnchor::Lines(lines) => lines,\n        FileAnchor::Gone => bail!(\"Nothing to anchor a comment to in {scope}\"),\n        FileAnchor::Unanchorable => {\n            bail!(\"Cannot comment on {scope}: the diff is binary or too large\")\n        }\n    };\n    let line = file\n        .line_at(comment.side, comment.line_number)\n        .with_context(|| {\n            format!(\n                \"No line {} on the {} side in {scope}\",\n                comment.line_number,\n                comment.side.as_str(),\n            )\n        })?;\n\n    // Snapshot the same-side neighbouring lines too: they disambiguate between identical\n    // lines when the comment is re-located later.\n    let line_before = (comment.line_number > 1)\n        .then(|| file.line_at(comment.side, comment.line_number - 1))\n        .flatten()\n        .map(|line| line.content.clone());","sourceCodeStart":122,"sourceCodeEnd":158,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/caf1f223d3cfb94488c9198ad34487c6006c648f/crates/but-comments/src/lib.rs#L122-L158","documentation":"create_comment() classified the file as FileAnchor::Unanchorable: the diff for {scope} is binary or exceeds the size threshold the diff machinery allows, so no line model exists and line comments are impossible by design.","triggerScenarios":"Attempting a line comment on a binary file (image, compiled artifact, lockfile marked binary) or a text file whose diff is too large for the anchored-diff representation.","commonSituations":"Reviewing generated files, vendored blobs, or minified bundles; large SQL/CSV data changes; users clicking 'comment' on a diff view the backend refuses to model.","solutions":["Use a non-line-scoped comment (commit/file level) for that path instead","Mark the file binary or exclude it from review if it is generated output","Split the change so the file's diff fits under the size threshold","If the file is genuinely reviewable text, check .gitattributes rules that misclassify it (e.g. -diff)"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// cheap pre-checks before offering line comments\nlet is_binary = std::fs::read(&path).is_ok_and(|b| b.contains(&0));\nlet too_large = std::fs::metadata(&path).map(|m| m.len() > MAX_REVIEWABLE).unwrap_or(true);\nif is_binary || too_large { ui.disable_line_comments(&path); }","typeGuard":null,"tryCatchPattern":"match create_comment(...) {\n    Err(e) if e.to_string().contains(\"binary or too large\") =>\n        create_file_level_note(comment).await, // degrade, don't fail\n    r => r?,\n}","preventionTips":["Mark known binary/generated paths in .gitattributes so tooling can skip them","Hide the comment button on binary or oversized diffs in the UI","Split oversized changes so review tooling can model the diff"],"tags":["comments","diff","binary-file","large-file"],"backgroundTag":"binary-file-diff","analyzedSha":"caf1f223d3cfb94488c9198ad34487c6006c648f","analyzedAt":"2026-08-20T07:55:40.983Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}