{"record":{"id":"3d76e1109b5ef41e","repo":"rtk-ai/rtk","slug":"format-b-must-parse","errorCode":null,"errorMessage":"--format=%B must parse","messagePattern":"--format=%B must parse","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmds/git/diff_cmd.rs","lineNumber":6386,"sourceCode":"        assert!(\n            out.contains(\"[file] \\\"caf\\\\351.txt\\\" (+1 -1)\"),\n            \"got:\\n{out}\"\n        );\n        assert!(!out.contains('\\u{FFFD}'), \"got:\\n{out}\");\n    }\n\n    #[test]\n    fn git_stat_separator_and_format_b_prose_condense() {\n        // Real `git log --stat -p`: a bare `---` between the message and\n        // the diffstat used to read as lost content.\n        let stat = include_str!(\"../../../tests/fixtures/diff/git_log_p_stat_raw.txt\");\n        let out = condense_unified_diff_strict(stat).expect(\"--stat -p must parse\");\n        assert!(out.contains(\"[file] i.py (+1 -1)\"), \"got:\\n{out}\");\n        assert!(out.contains(\"[file] m.txt (mode changed)\"), \"got:\\n{out}\");\n        // Real `git show --format=%B`: body prose starting with `diff `\n        // used to arm the GNU latch and send the stream raw.\n        let b = include_str!(\"../../../tests/fixtures/diff/git_show_format_B_raw.txt\");\n        let out = condense_unified_diff_strict(b).expect(\"--format=%B must parse\");\n        assert_eq!(out, \"[file] w.txt (+1 -0)\\n+zz\");\n    }\n\n    #[test]\n    fn combined_diffs_with_three_parents_parse() {\n        // Real octopus merge: `@@@@` with three old ranges, via `git show\n        // --cc` and via `git diff-tree -c` (`diff --combined`).\n        for fixture in [\n            include_str!(\"../../../tests/fixtures/diff/git_show_cc_octopus_raw.txt\"),\n            include_str!(\"../../../tests/fixtures/diff/git_diff_tree_combined_raw.txt\"),\n        ] {\n            let out = condense_unified_diff_strict(fixture).expect(\"must parse\");\n            assert_eq!(out, \"[file] x.txt (+1 -1)\\n---2\\n+++EVIL\");\n        }\n    }\n\n    #[test]\n    fn svn_copy_target_without_content_is_listed() {","sourceCodeStart":6368,"sourceCodeEnd":6404,"githubUrl":"https://github.com/rtk-ai/rtk/blob/0924356b4caba4989607227b7c8824d3d8098719/src/cmds/git/diff_cmd.rs#L6368-L6404","documentation":"The test `git_show_format_B` in src/cmds/git/diff_cmd.rs calls `condense_unified_diff_strict(b).expect(\"--format=%B must parse\")`. `condense_unified_diff_strict` (diff_cmd.rs:2083) returns `Option<String>` and yields `None` whenever the strict unified-diff state machine decides a stream is not a parseable diff (unsupported line shapes, prose misclassification, unterminated regions). The panic means the strict parser rejected the `git show --format=%B` fixture instead of condensing it to `[file] w.txt (+1 -0)`. The fixture's body prose starting with `diff ` is designed to exercise the GNU-latch rules; a parser regression re-arms the latch and the stream is sent raw or rejected.","triggerScenarios":"Running `cargo test` when condense_unified_diff_strict returns None for tests/fixtures/diff/git_show_format_B_raw.txt. Happens after edits to the parser's GNU latch, mbox message region, or file-header recognition rules in diff_cmd.rs.","commonSituations":"A contributor refactors the diff condensing rules and breaks recognition of `git show --format=%B` output whose commit body contains a line starting with `diff `; a fixture is regenerated with content the strict parser no longer accepts.","solutions":["Run `cargo test git_show_format_B` with a debug print inside condense_unified_diff_strict to find the line where parsing bails to None","Check the GNU latch (`gnu_diff_r`) state transitions around the `diff ` line in the fixture message body","Verify the fixture still matches real `git show --format=%B` output; regenerate with `git show --format=%B <sha>` if it drifted","Diff recent commits touching diff_cmd.rs rules 5/8 and revert the offending state-machine change"],"exampleFix":"// before\nlet out = condense_unified_diff_strict(b).expect(\"--format=%B must parse\");\n// after (diagnosing, keep expect in final code)\nlet out = match condense_unified_diff_strict(b) {\n    Some(o) => o,\n    None => panic!(\"strict parser returned None for git_show_format_B fixture\"),\n};","handlingStrategy":"try-catch","validationCode":"// Before running the full suite, check the fixture still parses:\nlet b = include_str!(\"../../../tests/fixtures/diff/git_show_format_B_raw.txt\");\nif condense_unified_diff_strict(b).is_none() {\n    eprintln!(\"git_show_format_B fixture no longer parses\");\n}","typeGuard":null,"tryCatchPattern":"// Isolate the failure with a descriptive panic instead of a bare expect:\nlet out = condense_unified_diff_strict(b).unwrap_or_else(||\n    panic!(\"strict parser returned None for git_show_format_B_raw fixture\"));","preventionTips":["When touching diff_cmd.rs parser rules, run the diff test module (`cargo test diff_cmd`) before committing","Keep fixtures generated from real tool output and re-verify them when bumping git/diffutils versions","Add temporary eprintln! tracing at every None bail-out in condense_unified_diff_strict when debugging","Cover each parser rule (mbox, GNU latch, no-index) with at least one fixture test so regressions are localized"],"tags":["rust","git","diff","testing","parser"],"backgroundTag":"diff-parse-failed","analyzedSha":"0924356b4caba4989607227b7c8824d3d8098719","analyzedAt":"2026-09-19T19:25:29.612Z","contentChangedAt":"2026-09-19T19:25:29.612Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}