Hmbown/CodeWhale · error

expected review command

Error message

expected review command

What it means

Test-only panic in crates/tui/src/lib.rs:15885 inside the shared helper `review_args(argv)`. It parses the given argv and destructures `Commands::Review(args)` via let-else; if the parsed command is not Review, it panics with "expected review command". Every review CLI test funnels through this helper, so any change to the `review` subcommand surface fails all of them here first.

Solutions

  1. Verify `Commands::Review(ReviewArgs)` is still a subcommand with the flags the tests pass.
  2. Panic with the actual parsed command (`got {:?}`) inside review_args for diagnosis.
  3. Fix the specific test argv that no longer parses, or update review_args if the variant was renamed.
  4. Run `cargo test -p codewhale-tui --lib review_` to see which argv variants break.

Example fix

// before
let Some(Commands::Review(args)) = cli.command else {
    panic!("expected review command");
};
// after
let Some(Commands::Review(args)) = cli.command else {
    panic!("expected review command, got {:?}", cli.command);
};
Defensive patterns

Strategy: validation

Validate before calling

fn review_args(argv: &[&str]) -> ReviewArgs {
    match parse_cli(argv).command {
        Some(Commands::Review(args)) => args,
        other => panic!("expected review command for {argv:?}, got {other:?}"),
    }
}

Type guard

fn as_review(cmd: &Option<Commands>) -> Option<&ReviewArgs> {
    match cmd { Some(Commands::Review(a)) => Some(a), _ => None }
}

Prevention

When it happens

Trigger: Any argv passed to review_args parses to a non-Review variant or None — the `Commands::Review` subcommand was renamed, its flags changed arity, or a top-level flag now consumes the first tokens.

Common situations: Renaming the review subcommand or ReviewArgs flags; a new global flag (like `--prompt` num_args=1..) swallowing "review"; a test passing flags that no longer exist.

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 Hmbown/CodeWhale@433685b202 (2026-09-15). Data as JSON: /api/errors/5530836d5e49ce0d. Report an issue: GitHub.

Appendix: source

Thrown at crates/tui/src/lib.rs:15885

        let receipt = crate::tools::review::build_review_receipt(
            "working tree",
            "diff --git a/a b/a",
            provider,
            &route.model,
            &output,
            "{}",
            Vec::new(),
        );
        assert_eq!(receipt.provider, "custom-a");
        let serialized = serde_json::to_string(&receipt).expect("review receipt");
        assert!(!serialized.contains("127.0.0.1"));
        assert!(!serialized.contains("local-test-key"));
    }

    fn review_args(argv: &[&str]) -> ReviewArgs {
        let cli = parse_cli(argv);
        let Some(Commands::Review(args)) = cli.command else {
            panic!("expected review command");
        };
        args
    }

    #[test]
    fn review_parses_provider_flag_alongside_model() {
        let args = review_args(&[
            "codewhale",
            "review",
            "--pr",
            "5709",
            "--provider",
            "zai",
            "--model",
            "GLM-5.3",
        ]);

        assert_eq!(args.provider.as_deref(), Some("zai"));

View on GitHub (pinned to 433685b202)