Hmbown/CodeWhale · error · anyhow::Error

--max-passes applies only to --pr reviews

Error message

--max-passes applies only to --pr reviews

What it means

Guard in the review-receipt/CLI argument validation path: the --max-passes flag limits repeated review iterations, which is only meaningful when reviewing a pull request (--pr). Passing --max-passes without --pr leaves the flag with no target, so validation rejects the combination up front rather than silently ignoring the option.

Solutions

  1. Add --pr if you intended a multi-pass PR review
  2. Remove --max-passes (or set it to 1) for non-PR reviews

Example fix

// before
codewhale review --max-passes 3
// after
codewhale review --pr 123 --max-passes 3
Defensive patterns

Strategy: validation

Validate before calling

if (!args.pr && args.max_passes !== 1) {
  throw new Error("--max-passes applies only to --pr reviews");
}

Prevention

When it happens

Trigger: Running a review without --pr while explicitly setting --max-passes to something other than 1.

Common situations: Reusing a PR-review command line for a local/diff review and forgetting to remove --max-passes; assuming multi-pass applies to all review modes.

Understand the failure class

Background: "unknown output mode", "invalid value for flag", "expects true/false": fixing invalid flag value errors in CLI tools — this error's family across 24 libraries.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22). Data as JSON: /api/errors/a1fa2d62630f2746. Report an issue: GitHub.

Appendix: source

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

}

fn resolve_review_model(config: &Config, explicit_model: Option<&str>) -> String {
    explicit_model
        .map(str::trim)
        .filter(|model| !model.is_empty())
        .map(str::to_string)
        .unwrap_or_else(|| config.default_model())
}

fn validate_review_receipt_args(args: &ReviewArgs) -> Result<()> {
    if args.receipt_path.is_some() && !args.write_receipt && !args.check_receipt {
        bail!("--receipt-path requires --write-receipt or --check-receipt");
    }
    if args.write_receipt && args.check_receipt {
        bail!("--write-receipt and --check-receipt are mutually exclusive");
    }
    if args.pr.is_none() && args.max_passes != 1 {
        bail!("--max-passes applies only to --pr reviews");
    }
    if !(1..=crate::tools::review::MAX_REVIEW_PASSES).contains(&args.max_passes) {
        bail!(
            "--max-passes must be from 1 to {}",
            crate::tools::review::MAX_REVIEW_PASSES
        );
    }
    Ok(())
}

fn run_review_receipt_check(
    diff: &str,
    args: &ReviewArgs,
    pr_view: Option<&GhPullRequest>,
) -> Result<()> {
    let (path, receipt) = if let Some(path) = args.receipt_path.as_ref() {
        (
            path.clone(),

View on GitHub (pinned to 73e0f67d83)