{"record":{"id":"836c5c2f0b2afa32","repo":"rtk-ai/rtk","slug":"must-parse","errorCode":null,"errorMessage":"must parse","messagePattern":"must parse","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmds/git/diff_cmd.rs","lineNumber":6084,"sourceCode":"            \"[file] tab\\there.txt.bin (binary)\",\n            \"[file] trail .txt (+1 -1)\",\n        ] {\n            assert!(out.contains(label), \"missing {label:?}:\\n{out}\");\n        }\n        // `hg log -p`: a `changeset:` prologue at column 0 before every\n        // changeset, then the two-`-r` echo; used to go raw on the latch.\n        let log = include_str!(\"../../../tests/fixtures/diff/hg_log_p_raw.txt\");\n        let out = condense_unified_diff_strict(log).expect(\"hg log -p must parse\");\n        assert!(out.contains(\"[file] bin.dat (binary)\"), \"got:\\n{out}\");\n        assert!(out.contains(\"[file] f.txt (+1 -1)\"), \"got:\\n{out}\");\n        assert!(out.contains(\"[file] new.txt (+1 -0)\"), \"got:\\n{out}\");\n        assert!(out.contains(\"[file] old.txt (+0 -1)\"), \"got:\\n{out}\");\n        assert!(!out.contains(\"summary\"), \"hg prologue leaked:\\n{out}\");\n        // A binary-only changeset whose message has a marked, non-prose-\n        // shaped line: hg's echo closes the region AND counts as reaching\n        // its body, so rule 8's shape check does not send it raw.\n        let bin = include_str!(\"../../../tests/fixtures/diff/hg_export_binary_only_raw.txt\");\n        let out = condense_unified_diff_strict(bin).expect(\"must parse\");\n        assert_eq!(out, \"[file] b.dat (binary)\");\n    }\n\n    #[test]\n    fn gnu_identical_and_differ_facts_are_entries() {\n        // Real `diff -rus` / `diff -rq`: `Files X and Y are identical` and\n        // `Files X and Y differ` share the `Binary files` shape.\n        let rus = include_str!(\"../../../tests/fixtures/diff/diff_rus_raw.txt\");\n        let out = condense_unified_diff_strict(rus).expect(\"must parse\");\n        assert!(out.contains(\"[file] g2/c.txt (+1 -1)\"), \"got:\\n{out}\");\n        assert!(out.contains(\"[file] g2/s.txt (identical)\"), \"got:\\n{out}\");\n        let rq = include_str!(\"../../../tests/fixtures/diff/diff_rq_raw.txt\");\n        let out = condense_unified_diff_strict(rq).expect(\"must parse\");\n        assert_eq!(out, \"[file] g2/c.txt (differs)\");\n    }\n\n    #[test]\n    fn a_leading_bom_does_not_hide_the_first_section() {","sourceCodeStart":6066,"sourceCodeEnd":6102,"githubUrl":"https://github.com/rtk-ai/rtk/blob/0924356b4caba4989607227b7c8824d3d8098719/src/cmds/git/diff_cmd.rs#L6066-L6102","documentation":"Test panic from `condense_unified_diff_strict(bin).expect(\"must parse\")` in src/cmds/git/diff_cmd.rs:6084. The test uses tests/fixtures/diff/hg_export_binary_only_raw.txt: a binary-only hg changeset whose message contains a marked, non-prose-shaped line. The expectation encodes an invariant: hg's command echo both closes the region and counts as reaching its body, so the shape check (rule 8) must NOT send the output raw, and the result must be exactly \"[file] b.dat (binary)\". A panic means the condenser returned Err for this fixture.","triggerScenarios":"`cargo test` after edits to the raw-passthrough shape check or the echo-closes-region logic; a regression makes the binary-only changeset fail to parse.","commonSituations":"Loosening or reordering the shape-based raw fallback so a binary-only diff with an unusual commit message is treated as unparseable prose.","solutions":["Run `cargo test hg_diff_echo_carries_one_revision -- --nocapture` to see the failure","Confirm hg's echo still marks region closure AND body-reached state in the latch state machine","Verify rule 8's shape check runs after the body-reached update, not before","Keep the assert_eq!(out, \"[file] b.dat (binary)\") strictness — do not loosen the assertion to hide the regression"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"let bin = include_str!(\"../../../tests/fixtures/diff/hg_export_binary_only_raw.txt\");\nassert!(bin.contains(\"b.dat\"), \"fixture must reference the binary file\");","typeGuard":"fn parsed_or_none(r: Result<String, ParseError>) -> Option<String> { r.ok() }","tryCatchPattern":"let out = condense_unified_diff_strict(bin)\n    .unwrap_or_else(|e| panic!(\"binary-only changeset must parse: {e}\"));\nassert_eq!(out, \"[file] b.dat (binary)\");","preventionTips":["Keep strict output assertions — do not loosen them to mask regressions","Cover binary-only changesets with unusual commit messages in fixtures","Re-run hg fixture tests after edits to the shape-based raw fallback (rule 8)"],"tags":["rust","tests","hg","binary-diff","panic"],"backgroundTag":"internal-invariant-violation","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"}