Hmbown/CodeWhale · error · anyhow::Error

Review receipt check failed

Error message

Review receipt check failed: {}

What it means

A receipt validation performed with --check-receipt did not pass: ReviewReceiptValidation.passed was false and validation.reason explains why. The command bails so CI/automation sees a non-zero exit when the receipt does not match the review it claims to certify.

Solutions

  1. Read the `{}` reason in the message for the specific validation failure
  2. Re-run the review with --write-receipt to generate a fresh, matching receipt
  3. Verify you are checking the receipt file that corresponds to this exact review/PR

Example fix

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

Strategy: try-catch

Validate before calling

// pre-check the receipt file exists and is well-formed JSON before --check-receipt
const fs = require('fs');
const receipt = JSON.parse(fs.readFileSync(path, 'utf8'));
if (!receipt || !receipt.review) throw new Error("malformed receipt file");

Try / catch

match on `codewhale review --check-receipt` exit; on failure, log the reason embedded in "Review receipt check failed: {reason}" and regenerate the receipt with --write-receipt

Prevention

When it happens

Trigger: Running `codewhale review --check-receipt --receipt-path <file>` where the receipt's contents fail validation (validation.reason carries the specific mismatch).

Common situations: Checking a receipt generated from an older code version against a new review; a receipt file that was edited or belongs to a different PR; tamper/integrity verification failing in CI.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


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

Appendix: source

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

        validation.reason =
            "review receipt does not match the current PR base/head revision".into();
    }

    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 73e0f67d83)