{"record":{"id":"1700f850cbae10a7","repo":"rtk-ai/rtk","slug":"a-table-in-the-message-must-not-force-raw","errorCode":null,"errorMessage":"a table in the message must not force raw","messagePattern":"a table in the message must not force raw","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/cmds/git/diff_cmd.rs","lineNumber":6917,"sourceCode":"        // 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\n        // a ` | `, but it is prose: the bullet after it must stay prose too,\n        // not read as a marked line past the diffstat.\n        let base = \"From fe6a6d0d8316535b5ac232f5d7cc6d227b187b9e Mon Sep 17 00:00:00 2001\\nSubject: [PATCH] one\\n\\n col | val\\n --- | ---\\n row | text\\n- a bullet after the table\\n---\\nSTAT\\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\";\n        let out = condense_unified_diff_strict(&base.replace(\"STAT\", \" x.txt | 2 +-\"))\n            .expect(\"a table in the message must not force raw\");\n        assert!(out.contains(\"[file] x.txt (+1 -1)\"), \"got:\\n{out}\");\n        assert!(!out.contains(\"bullet\"), \"got:\\n{out}\");\n\n        // Every diffstat shape format-patch emits still ends the tolerance,\n        // so a marked line after one is still lost content. The bare count\n        // covers a pure rename or mode change, which stats as `0`.\n        for stat in [\n            \" x.txt                        |   2 +-\",\n            \" added.txt                    |   1 +\",\n            \" img.png                      | Bin 7 -> 12 bytes\",\n            \" img.png                      | Bin\",\n            \" rename_me.txt => renamed.txt |   0\",\n            \" {a => b}/file.txt            |   2 +-\",\n            \" a | b.txt                    |   2 +-\",\n        ] {\n            let lost = base.replace(\"STAT\", stat).replace(\n                \"\\ndiff --git a/x.txt b/x.txt\\n--- a/x.txt\\n+++ b/x.txt\\n@@ -1 +1 @@\\n\",\n                \"\\n\",","sourceCodeStart":6899,"sourceCodeEnd":6935,"githubUrl":"https://github.com/rtk-ai/rtk/blob/0924356b4caba4989607227b7c8824d3d8098719/src/cmds/git/diff_cmd.rs#L6899-L6935","documentation":"Test panic from `.expect(\"a table in the message must not force raw\")`: `condense_unified_diff_strict` returned `Err` on a format-patch whose commit message contains a space-indented markdown table (`col | val`) with ` | ` cells. The parser must recognize the table as prose (not a diffstat), keep parsing, and not fall back to raw output; the test also asserts the bullet after the table stays prose.","triggerScenarios":"Input with a `Subject: [PATCH]` header, a message body containing ` | `-containing table rows, one `- ` bullet, then `---`, the diffstat ` x.txt | 2 +-`, and a normal diff hunk — a heuristic that treats any post-message `|` line as a marked line or forces raw on table-like content triggers the panic.","commonSituations":"Commit messages embedding markdown tables (changelogs, benchmark results) collide with diffstat heuristics keyed on ` | `.","solutions":["Log the parser's actual error and the input to see which line the table heuristic trips on.","Require diffstat lines to match the `path | N +-` shape with a leading space AND be followed by the `N file(s) changed` summary line before treating subsequent bullets as marked lines.","If the fallback to raw is correct for some table shapes, restrict the strict-parse test to the space-indented case covered here."],"exampleFix":"// before\n.expect(\"a table in the message must not force raw\");\n// after\n.unwrap_or_else(|e| panic!(\"a table in the message must not force raw: {e}\\n{out}\"));","handlingStrategy":"validation","validationCode":"// pre-check: prose table lines are indented and not in the diffstat window\nlet is_diffstat = |l: &str| l.starts_with(' ') && l.contains(\" | \") && l.split(\"|\").count() == 2;","typeGuard":null,"tryCatchPattern":"let out = condense_unified_diff_strict(&input)\n    .unwrap_or_else(|e| panic!(\"table must not force raw: {e}\\n{input}\"));","preventionTips":["Key diffstat detection on the `N file(s) changed` summary line, not on ` | ` alone","Keep markdown-table prose samples in the fixture list","Log the failing line index/offset when strict parse rejects input"],"tags":["rust","test-assertion","heuristic"],"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"}