Hmbown/CodeWhale · error · anyhow::Error

Review receipt check failed: {}

Error message

Review receipt check failed: {}

What it means

After a `--check-receipt` run, run_review_receipt_check() inspects the ReviewReceiptValidation and bails with its reason when validation.passed is false. The validator produces three concrete reasons: an unsupported receipt schema version, "current diff fingerprint does not match receipt" (the diff text changed since the receipt was written), or an unresolved risk recorded on the receipt (its summary becomes the reason).

Source

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

    };
    let validation =
        crate::tools::review::validate_review_receipt_for_diff(diff, &receipt, Some(path.clone()));

    if args.json {
        println!(
            "{}",
            serde_json::to_string_pretty(&serde_json::json!({
                "mode": "review_receipt_check",
                "success": validation.passed,
                "validation": review_receipt_validation_public_json(&validation),
            }))?
        );
    } else if validation.passed {
        println!("Review receipt valid: {}", path.display());
    }

    if !validation.passed {
        bail!("Review receipt check failed: {}", validation.reason);
    }
    Ok(())
}

fn review_receipt_validation_public_json(
    validation: &crate::tools::review::ReviewReceiptValidation,
) -> serde_json::Value {
    let unresolved_risk = validation.unresolved_risk.as_ref();
    serde_json::json!({
        "passed": validation.passed,
        "status": review_receipt_validation_status(validation),
        "diff_fingerprint": validation.diff_fingerprint.as_str(),
        "receipt_fingerprint": validation.receipt_fingerprint.as_deref(),
        "unresolved": unresolved_risk.is_some_and(|risk| risk.unresolved),
        "risk_level": unresolved_risk.map(|risk| risk.level.as_str()),
    })
}

View on GitHub (pinned to 0c42157ee5)

Solutions

  1. Re-run the review with `--write-receipt` against the exact current diff, then `--check-receipt` again
  2. Ensure the check uses the identical diff selection (--staged/--base/--path) as the write
  3. If the reason is unresolved risk, address the review findings before re-reviewing
  4. For schema-version reasons, regenerate the receipt with the current codewhale version

Example fix

// before: diff changed since the receipt was written
$ codewhale review --check-receipt --receipt-path r.json
Error: Review receipt check failed: current diff fingerprint does not match receipt

// after: re-review the exact current diff, then check
$ codewhale review --write-receipt --receipt-path r.json
$ codewhale review --check-receipt --receipt-path r.json
Defensive patterns

Strategy: try-catch

Validate before calling

# the fingerprint covers the diff text; detect drift before checking
now=$(git diff | sha256sum)
[ "$now" = "$AT_WRITE_TIME" ] || echo 'diff changed since receipt write'

Try / catch

codewhale review --check-receipt --receipt-path r.json || {
  echo 'receipt no longer matches the diff; re-run --write-receipt' >&2; exit 1
}

Prevention

When it happens

Trigger: Checking a receipt whose diff_fingerprint differs from the currently collected diff (any edit, rebase, or a different --staged/--base/--path selection than the writing run); a receipt from an older schema version; a receipt whose review recorded unresolved_risk.

Common situations: Editing code between the review that wrote the receipt and the check; rebasing; CI enforcing receipts on merges; regenerating receipts across codewhale versions.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@0c42157ee5 (2026-08-20). Data as JSON: /api/errors/e6b7246df6121a02. Report an issue: GitHub.