{"record":{"id":"cafb09ce23fa3799","repo":"rtk-ai/rtk","slug":"intact-series-must-parse","errorCode":null,"errorMessage":"intact series must parse","messagePattern":"intact series must parse","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/cmds/git/diff_cmd.rs","lineNumber":6894,"sourceCode":"    #[test]\n    fn mbox_marked_lines_past_the_diffstat_fall_back_to_raw() {\n        // A format-patch series with the second patch's `diff --git` /\n        // `---` / `+++` / `@@` block stripped (a hand-edited patch, a mail\n        // client's reflow). The orphaned hunk body sits in the mbox message\n        // region past the diffstat, where the prose exemption used to\n        // swallow it; nothing in the output suggested it was incomplete.\n        let series = \"From fe6a6d0d8316535b5ac232f5d7cc6d227b187b9e Mon Sep 17 00:00:00 2001\\nSubject: [PATCH 1/2] one\\n\\n- a bullet in the message\\n---\\n x.txt | 2 +-\\n 1 file changed, 1 insertion(+), 1 deletion(-)\\n\\ndiff --git a/x.txt b/x.txt\\n--- a/x.txt\\n+++ b/x.txt\\n@@ -1 +1 @@\\n-a\\n+b\\n-- \\n2.54.0\\n\\nFrom 0e7632a01b00c70cbc9dafcf1f23c71fa6b10de1 Mon Sep 17 00:00:00 2001\\nSubject: [PATCH 2/2] two\\n\\n- another bullet\\n---\\n y.txt | 2 +-\\n 1 file changed, 1 insertion(+), 1 deletion(-)\\n\\n-p\\n+q\\n-- \\n2.54.0\\n\";\n        assert!(\n            condense_unified_diff_strict(series).is_none(),\n            \"orphaned hunk body in an mbox region was dropped\"\n        );\n        // The intact series (with the block restored) still parses, bullets\n        // and separators included, and the signature is not counted.\n        let intact = series.replace(\n            \"\\n-p\\n+q\\n\",\n            \"\\ndiff --git a/y.txt b/y.txt\\n--- a/y.txt\\n+++ b/y.txt\\n@@ -1 +1 @@\\n-p\\n+q\\n\",\n        );\n        let out = condense_unified_diff_strict(&intact).expect(\"intact series must parse\");\n        assert!(out.contains(\"[file] y.txt (+1 -1)\"), \"got:\\n{out}\");\n        assert!(!out.contains(\"bullet\"), \"got:\\n{out}\");\n        // Version notes between `---` and the diffstat (the kernel / b4\n        // convention) are column-0 bullets past the separator; they must\n        // stay prose, which is why the tolerance ends at the diffstat and\n        // not at `---`.\n        let notes = intact.replace(\n            \"---\\n y.txt | 2 +-\",\n            \"---\\nChanges in v2:\\n- rebased\\n- dropped the hack\\n\\n y.txt | 2 +-\",\n        );\n        let out = condense_unified_diff_strict(&notes).expect(\"version notes must stay prose\");\n        assert!(out.contains(\"[file] y.txt (+1 -1)\"), \"got:\\n{out}\");\n        assert!(!out.contains(\"rebased\"), \"got:\\n{out}\");\n    }\n\n    #[test]\n    fn a_prose_table_is_not_a_diffstat() {\n        // A markdown table in the commit message is space-indented and holds","sourceCodeStart":6876,"sourceCodeEnd":6912,"githubUrl":"https://github.com/rtk-ai/rtk/blob/0924356b4caba4989607227b7c8824d3d8098719/src/cmds/git/diff_cmd.rs#L6876-L6912","documentation":"Test panic from `.expect(\"intact series must parse\")`: `condense_unified_diff_strict` returned `Err` on a format-patch series that should still be parseable after a block is restored mid-series. The strict parser refuses input whose structure (bullets, separators, diffstat boundary) it cannot trust, and the test guarantees a well-formed intact series is accepted, with the restored y.txt file reported and no prose misclassified as bullets.","triggerScenarios":"Calling `condense_unified_diff_strict` with a multi-file format-patch body where inserting `diff --git a/y.txt b/y.txt ... -p +q` before an existing block makes the strict parser bail (e.g. bullet tolerance window exceeded or separator detection fails).","commonSituations":"Kernel/b4-style patch series with version notes and multiple diff blocks; regressions introduced when tightening strict-mode tolerance so it ends at the diffstat rather than at `---`.","solutions":["Print the parser's error message (`expect` swallows context) by replacing the expect with a match that logs `err` and the input series.","Verify the bullet/separator tolerance logic still terminates the prose window at the diffstat line, not earlier.","If intentionally stricter, update the test fixture to a shape the strict parser accepts."],"exampleFix":"// before\nlet out = condense_unified_diff_strict(&intact).expect(\"intact series must parse\");\n// after\nlet out = condense_unified_diff_strict(&intact)\n    .unwrap_or_else(|e| panic!(\"intact series must parse: {e}\\ninput:\\n{intact}\"));","handlingStrategy":"validation","validationCode":"// sanity-check the series shape before strict parsing\nassert!(series.contains(\"diff --git \") && series.contains(\"@@ -1 +1 @@\"));","typeGuard":null,"tryCatchPattern":"let out = condense_unified_diff_strict(&intact)\n    .unwrap_or_else(|e| panic!(\"intact series must parse: {e}\\ninput:\\n{intact}\"));","preventionTips":["Always surface the parser's error message inside expect/panic, never a bare string","Add every real-world series shape (kernel/b4) as a fixture","Document where the strict tolerance window ends (diffstat, not ---)"],"tags":["rust","test-assertion","diff-parsing"],"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"}