rtk-ai/rtk · error

must parse

Error message

must parse

What it means

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.

Solutions

  1. Run `cargo test hg_diff_echo_carries_one_revision -- --nocapture` to see the failure
  2. Confirm hg's echo still marks region closure AND body-reached state in the latch state machine
  3. Verify rule 8's shape check runs after the body-reached update, not before
  4. Keep the assert_eq!(out, "[file] b.dat (binary)") strictness — do not loosen the assertion to hide the regression
Defensive patterns

Strategy: try-catch

Validate before calling

let bin = include_str!("../../../tests/fixtures/diff/hg_export_binary_only_raw.txt");
assert!(bin.contains("b.dat"), "fixture must reference the binary file");

Type guard

fn parsed_or_none(r: Result<String, ParseError>) -> Option<String> { r.ok() }

Try / catch

let out = condense_unified_diff_strict(bin)
    .unwrap_or_else(|e| panic!("binary-only changeset must parse: {e}"));
assert_eq!(out, "[file] b.dat (binary)");

Prevention

When it happens

Trigger: `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.

Common situations: Loosening or reordering the shape-based raw fallback so a binary-only diff with an unusual commit message is treated as unparseable prose.

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/836c5c2f0b2afa32. Report an issue: GitHub.

Appendix: source

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

            "[file] tab\there.txt.bin (binary)",
            "[file] trail .txt (+1 -1)",
        ] {
            assert!(out.contains(label), "missing {label:?}:\n{out}");
        }
        // `hg log -p`: a `changeset:` prologue at column 0 before every
        // changeset, then the two-`-r` echo; used to go raw on the latch.
        let log = include_str!("../../../tests/fixtures/diff/hg_log_p_raw.txt");
        let out = condense_unified_diff_strict(log).expect("hg log -p must parse");
        assert!(out.contains("[file] bin.dat (binary)"), "got:\n{out}");
        assert!(out.contains("[file] f.txt (+1 -1)"), "got:\n{out}");
        assert!(out.contains("[file] new.txt (+1 -0)"), "got:\n{out}");
        assert!(out.contains("[file] old.txt (+0 -1)"), "got:\n{out}");
        assert!(!out.contains("summary"), "hg prologue leaked:\n{out}");
        // A binary-only changeset whose message has a marked, non-prose-
        // shaped line: hg's echo closes the region AND counts as reaching
        // its body, so rule 8's shape check does not send it raw.
        let bin = include_str!("../../../tests/fixtures/diff/hg_export_binary_only_raw.txt");
        let out = condense_unified_diff_strict(bin).expect("must parse");
        assert_eq!(out, "[file] b.dat (binary)");
    }

    #[test]
    fn gnu_identical_and_differ_facts_are_entries() {
        // Real `diff -rus` / `diff -rq`: `Files X and Y are identical` and
        // `Files X and Y differ` share the `Binary files` shape.
        let rus = include_str!("../../../tests/fixtures/diff/diff_rus_raw.txt");
        let out = condense_unified_diff_strict(rus).expect("must parse");
        assert!(out.contains("[file] g2/c.txt (+1 -1)"), "got:\n{out}");
        assert!(out.contains("[file] g2/s.txt (identical)"), "got:\n{out}");
        let rq = include_str!("../../../tests/fixtures/diff/diff_rq_raw.txt");
        let out = condense_unified_diff_strict(rq).expect("must parse");
        assert_eq!(out, "[file] g2/c.txt (differs)");
    }

    #[test]
    fn a_leading_bom_does_not_hide_the_first_section() {

View on GitHub (pinned to 0924356b4c)