{"record":{"id":"0c799c68386f60d9","repo":"Hmbown/CodeWhale","slug":"sha256-mismatch-for-from-expected-expec","errorCode":null,"errorMessage":"SHA256 mismatch for {} from {}!\n  expected: {expected}\n  actual:   {actual}","messagePattern":"SHA256 mismatch for (.+?) from (.+?)!\n  expected: (.+?)\n  actual:   (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"crates/cli/src/update.rs","lineNumber":222,"sourceCode":"\n/// Fail closed when the downloaded bytes do not match the manifest that came\n/// from the same source. A mismatch is never a reason to install anyway, and\n/// never a reason to retry against the source that lost the probe: the two\n/// build their own artifacts, so their checksums are not interchangeable.\nfn verify_downloaded_asset(download: &DownloadPlan, bytes: &[u8]) -> Result<()> {\n    let expected = download\n        .checksums\n        .get(&download.binary_name)\n        .with_context(|| {\n            format!(\n                \"{CHECKSUM_MANIFEST_ASSET} from {} is missing {}\",\n                download.source.describe(),\n                download.binary_name\n            )\n        })?;\n    let actual = sha256_hex(bytes);\n    if !actual.eq_ignore_ascii_case(expected) {\n        bail!(\n            \"SHA256 mismatch for {} from {}!\\n  expected: {expected}\\n  actual:   {actual}\",\n            download.binary_name,\n            download.source.describe()\n        );\n    }\n    Ok(())\n}\n\n/// Explain how to move to GitHub releases without overwriting managed files.\nfn managed_install_warning(method: InstallMethod) -> Option<String> {\n    if method.supports_self_update() {\n        return None;\n    }\n    Some(format!(\n        \"This executable is managed by {label}; in-place self-update is disabled.\\n\\n\\\n         {GITHUB_MIGRATION_HELP}\\n\\n\\\n         To retain this secondary {label} installation, run `{command}`.\",\n        label = method.label(),","sourceCodeStart":204,"sourceCodeEnd":240,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/cli/src/update.rs#L204-L240","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Retry the download — a transient corruption will produce a different hash on a clean retry.","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.","Verify the expected digest in the release manifest matches the published release checksums.","Inspect for a proxy/SSL-intercepting middlebox altering response bytes."],"exampleFix":"// before\nmirror = \"https://stale-mirror.example.com/codewhale\"\n// after\nmirror = null  // fall back to official release source that matches the manifest","handlingStrategy":"retry","validationCode":"// verify downloaded bytes yourself before trusting them\nlet actual = sha256_hex(&bytes);\nassert_eq!(actual.to_ascii_lowercase(), expected.to_ascii_lowercase());","typeGuard":null,"tryCatchPattern":"match run_update().await {\n    Err(e) if e.to_string().contains(\"SHA256 mismatch\") => {\n        // clear pinned mirror / disable proxy, then retry download once\n        eprintln!(\"checksum failed; retry from official source\");\n    }\n    other => other?,\n}","preventionTips":["Avoid pinned mirrors that can drift from the signed manifest.","Disable SSL-intercepting proxies or add the CA properly when downloading release artifacts.","Retry once on transient network errors before reporting checksum failure.","Compare published release checksums with the manifest you download from."],"tags":["security","checksum","self-update","network"],"backgroundTag":"checksum-mismatch","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}