Hmbown/CodeWhale · error · anyhow::Error

--write-receipt and --check-receipt are mutually exclusive

Error message

--write-receipt and --check-receipt are mutually exclusive

What it means

CLI validation rejecting conflicting receipt modes: --write-receipt creates a new receipt while --check-receipt validates an existing one; performing both in a single invocation is ambiguous, so the combination is refused.

Solutions

  1. Keep only --write-receipt to produce a receipt
  2. Keep only --check-receipt to validate an existing receipt
  3. Split into two invocations: first check the old receipt, then write a new one

Example fix

// before
codewhale review --pr 123 --write-receipt --check-receipt --receipt-path r.json
// after
codewhale review --pr 123 --check-receipt --receipt-path r.json
Defensive patterns

Strategy: validation

Validate before calling

if (args.write_receipt && args.check_receipt) {
  throw new Error("use --write-receipt or --check-receipt, not both");
}

Prevention

When it happens

Trigger: Running `codewhale review ... --write-receipt --check-receipt` in the same command.

Common situations: Script templating that appends both flags unconditionally; confusing the write and check modes when chaining review runs.

Understand the failure class

Background: "mutually exclusive" flag errors: what "can't supply both nx and xx", "--raw is not compatible with -i" and "cannot be used with" mean, and how to fix them — this error's family across 29 libraries.

Related errors


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

Appendix: source

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

fn non_empty_flag(value: Option<&str>) -> Option<&str> {
    value.map(str::trim).filter(|value| !value.is_empty())
}

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<()> {

View on GitHub (pinned to 73e0f67d83)