{"record":{"id":"511fb9992153002f","repo":"zed-industries/zed","slug":"raw-diff-is-missing-the-status","errorCode":null,"errorMessage":"raw diff is missing the status","messagePattern":"raw diff is missing the status","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/git/src/commit.rs","lineNumber":217,"sourceCode":"    let mut fields = metadata\n        .strip_prefix(':')\n        .context(\"raw diff metadata is missing its ':' prefix\")?\n        .split_ascii_whitespace();\n    let old_mode = fields.next().context(\"raw diff is missing the old mode\")?;\n    let new_mode = fields.next().context(\"raw diff is missing the new mode\")?;\n    let old_oid = fields\n        .next()\n        .context(\"raw diff is missing the old object ID\")?;\n    let new_oid = fields\n        .next()\n        .context(\"raw diff is missing the new object ID\")?;\n    let status = match fields.next() {\n        Some(\"M\") => StatusCode::Modified,\n        Some(\"T\") => StatusCode::TypeChanged,\n        Some(\"A\") => StatusCode::Added,\n        Some(\"D\") => StatusCode::Deleted,\n        Some(status) => anyhow::bail!(\"unsupported raw diff status {status}\"),\n        None => anyhow::bail!(\"raw diff is missing the status\"),\n    };\n\n    Ok(CommitDiffEntry {\n        path,\n        status,\n        old_object: (!old_oid.bytes().all(|byte| byte == b'0')).then(|| CommitDiffObject {\n            oid: old_oid,\n            kind: if old_mode == GITLINK_MODE {\n                CommitDiffObjectKind::Gitlink\n            } else {\n                CommitDiffObjectKind::Blob\n            },\n        }),\n        new_object: (!new_oid.bytes().all(|byte| byte == b'0')).then(|| CommitDiffObject {\n            oid: new_oid,\n            kind: if new_mode == GITLINK_MODE {\n                CommitDiffObjectKind::Gitlink\n            } else {","sourceCodeStart":199,"sourceCodeEnd":235,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/git/src/commit.rs#L199-L235","documentation":"The same raw-diff metadata parser bails when, after splitting the ':old_mode new_mode old_oid new_oid status' metadata on whitespace, there is no fifth field at all — i.e. git produced a metadata record with fewer tokens than the documented format. This is a contract violation between git's output and the parser, not a user-input error.","triggerScenarios":"A `git diff --raw -z` / `git diff-tree -r -z` metadata record missing its status token — caused by nonstandard git builds, output-mangling filters (external diff drivers writing to stdout), or locale/wrapper tools rewriting git output.","commonSituations":"Git wrappers or diff.external/diff.driver config polluting raw output, ancient or forked git versions with different --raw formats, or wrappers like hub/gh shims in PATH emitting extra content.","solutions":["Reproduce manually with `git diff-tree -r -z --abbrev=64 --no-renames <base> <head>` and inspect the metadata tokens","Check `git config --get diff.external` and core.pager/wrappers that could rewrite output, and unset them for raw diffs","Use a stock, current git release in PATH for the app"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// sanity-check a metadata record before parsing\nlet token_count = metadata.trim_start_matches(':').split_ascii_whitespace().count();\nif token_count != 5 { /* skip/log instead of parse */ }","typeGuard":"fn is_well_formed_raw_metadata(metadata: &str) -> bool {\n    metadata.strip_prefix(':')\n        .map(|m| m.split_ascii_whitespace().count() == 5)\n        .unwrap_or(false)\n}","tryCatchPattern":"Err(e) if e.to_string().contains(\"raw diff is missing\") => { /* log record and continue */ }","preventionTips":["Run raw-diff parsing only against stock git output; keep diff.external/wrappers unset for these invocations","Pin a known-good git version in CI and document it as the supported minimum"],"tags":["git","diff","parse","output-format"],"backgroundTag":"git-output-parse-error","analyzedSha":"f4178619acd0d47ea1f76a2025c42962c6d6638c","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}