rtk-ai/rtk · warning

a bodyless region of prose must not force raw

Error message

a bodyless region of prose must not force raw

What it means

Test panic from `.expect("a bodyless region of prose must not force raw")`: `condense_unified_diff_strict` returned `Err` for patch bodies whose prose contains column-0 lines that superficially look like marked lines — an ASCII rule (`---------`), a bullet (`- done`), or a wrapped command line reaching column 0 (`--no-stat --cover-letter`). The parser must not classify such bodyless prose as lost marked-line content, which would force raw output and fail the parse assertion.

Solutions

  1. Replace the expect with a match that includes the substituted prose in the panic message to identify which sample broke.
  2. Tighten the marked-line heuristic: only treat `- ` bullets past the diffstat as marked lines, not raw column-0 dashes or option-like lines inside the message body.
  3. Keep each prose shape as a regression fixture in the test list.

Example fix

// before
.expect("a bodyless region of prose must not force raw");
// after
.unwrap_or_else(|e| panic!("prose must not force raw: {e}\nprose sample:\n{prose}"));
Defensive patterns

Strategy: validation

Validate before calling

// heuristic pre-check: rule lines and option-like column-0 text are prose
let looks_like_marked = |l: &str| l.starts_with("- ") && !l.starts_with("---");

Try / catch

let out = condense_unified_diff_strict(&series.replace("BODY", prose))
    .unwrap_or_else(|e| panic!("prose must not force raw: {e}\nprose:\n{prose}"));

Prevention

When it happens

Trigger: Substituting each prose sample (rule line, bullet, long-option wrapped to column 0) into the BODY slot of a patch series template and calling `condense_unified_diff_strict`; the marked-line detector must tolerate these shapes and still emit `[file] y.txt (+1 -1)`.

Common situations: Commit messages wrapping long CLI options to column 0 (reported as ~11.7% of marked-line messages in this repo), ASCII underlines, and markdown bullets all mimic the marked-line shape.

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


AI-assisted analysis of rtk-ai/rtk@0924356b4c (2026-09-19). Data as JSON: /api/errors/bf3c91d6eb4e2b81. Report an issue: GitHub.

Appendix: source

Thrown at src/cmds/git/diff_cmd.rs:6972

        // Closing at end of stream, not at a separator, judges it the same.
        let last = "From bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb Mon Sep 17 00:00:00 2001\nSubject: [PATCH 1/2] one\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-- \n2.54.0\n\nFrom aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa Mon Sep 17 00:00:00 2001\nSubject: [PATCH 2/2] two\n\n-a\n+b\n-- \n2.54.0\n";
        assert!(
            condense_unified_diff_strict(last).is_none(),
            "an orphaned body at end of stream must fall back raw"
        );

        // Bodyless by construction - a cover letter or an `--always` empty
        // commit - writes bullets, and bullets keep their shape.
        for prose in [
            "- first, it changes a to b\n- second, it changes b to c",
            "Before and after:\n- old_value = 1\n+ new_value = 2",
            "A rule:\n---------\nand a bullet:\n- done",
            // Prose that wrapped a long option to column 0, which is how
            // 11.7% of this repo's marked-line messages break bullet shape.
            "The relevant invocation is\n--no-stat --cover-letter\nwhich changes nothing here.",
        ] {
            let out = condense_unified_diff_strict(&series.replace("BODY", prose))
                .expect("a bodyless region of prose must not force raw");
            assert!(out.contains("[file] y.txt (+1 -1)"), "got:\n{out}");
        }
    }

    #[test]
    fn u0_and_omitted_counts_parse() {
        // `-U0` produces `@@ -3 +3 @@` (omitted count = 1) and zero-count
        // ranges like `@@ -5,0 +6 @@`.
        let fixture = include_str!("../../../tests/fixtures/diff/git_diff_u0_raw.txt");
        let out = condense_unified_diff(fixture);
        assert_ne!(out, fixture, "-U0 fell back to raw");
        assert!(out.contains("[file] main.rs (+2 -1)"), "got:\n{out}");
    }

    // --- region parser: the safety net must fire on structural disagreement ---

    #[test]
    fn truncated_hunk_falls_back_to_raw() {

View on GitHub (pinned to 0924356b4c)