Hmbown/CodeWhale · critical

SHA256 mismatch for from ! expected: actual

Error message

SHA256 mismatch for {} from {}!
  expected: {expected}
  actual:   {actual}

What it means

verify_downloaded_asset computes the SHA256 of the freshly downloaded update asset and compares it case-insensitively with the expected digest from the release manifest. On mismatch it bails, failing closed so a corrupted, tampered, or wrong-version binary is never installed; the message names the asset and the download source that produced it.

Solutions

  1. Retry the download — a transient corruption will produce a different hash on a clean retry.
  2. Check the download source (download.source.describe()); if a mirror is pinned, remove or update the mirror config so downloads come from the official source matching the manifest.
  3. Verify the expected digest in the release manifest matches the published release checksums.
  4. Inspect for a proxy/SSL-intercepting middlebox altering response bytes.

Example fix

// before
mirror = "https://stale-mirror.example.com/codewhale"
// after
mirror = null  // fall back to official release source that matches the manifest
Defensive patterns

Strategy: retry

Validate before calling

// verify downloaded bytes yourself before trusting them
let actual = sha256_hex(&bytes);
assert_eq!(actual.to_ascii_lowercase(), expected.to_ascii_lowercase());

Try / catch

match run_update().await {
    Err(e) if e.to_string().contains("SHA256 mismatch") => {
        // clear pinned mirror / disable proxy, then retry download once
        eprintln!("checksum failed; retry from official source");
    }
    other => other?,
}

Prevention

When it happens

Trigger: Downloading an updater binary whose sha256 does not match the manifest's expected digest: truncated/corrupted download, a mirror serving different bytes than the signed manifest, MITM modification, or manifest/digest reuse across versions.

Common situations: Downloading through a corporate proxy or captive portal that rewrites content; pinned mirror out of sync with the manifest; flaky network truncating the download; compromised or stale mirror.

Understand the failure class

Background: Checksum mismatch errors: "checksum verification failed", "digest mismatch", "expected vs actual checksum" — what they mean and how to fix them — this error's family across 41 libraries.

Related errors


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

Appendix: source

Thrown at crates/cli/src/update.rs:222

/// Fail closed when the downloaded bytes do not match the manifest that came
/// from the same source. A mismatch is never a reason to install anyway, and
/// never a reason to retry against the source that lost the probe: the two
/// build their own artifacts, so their checksums are not interchangeable.
fn verify_downloaded_asset(download: &DownloadPlan, bytes: &[u8]) -> Result<()> {
    let expected = download
        .checksums
        .get(&download.binary_name)
        .with_context(|| {
            format!(
                "{CHECKSUM_MANIFEST_ASSET} from {} is missing {}",
                download.source.describe(),
                download.binary_name
            )
        })?;
    let actual = sha256_hex(bytes);
    if !actual.eq_ignore_ascii_case(expected) {
        bail!(
            "SHA256 mismatch for {} from {}!\n  expected: {expected}\n  actual:   {actual}",
            download.binary_name,
            download.source.describe()
        );
    }
    Ok(())
}

/// Explain how to move to GitHub releases without overwriting managed files.
fn managed_install_warning(method: InstallMethod) -> Option<String> {
    if method.supports_self_update() {
        return None;
    }
    Some(format!(
        "This executable is managed by {label}; in-place self-update is disabled.\n\n\
         {GITHUB_MIGRATION_HELP}\n\n\
         To retain this secondary {label} installation, run `{command}`.",
        label = method.label(),

View on GitHub (pinned to 73e0f67d83)