{"record":{"id":"7ea53eb97bb11689","repo":"jdx/mise","slug":"task-cache-artifact-checksum-mismatch","errorCode":null,"errorMessage":"task cache artifact checksum mismatch","messagePattern":"task cache artifact checksum mismatch","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/task/task_cache.rs","lineNumber":940,"sourceCode":"        execution_duration_ns: manifest.execution_duration_ns,\n        archive_checksum,\n    };\n    let encoded = serde_json::to_string(&material)?;\n    Ok(format!(\"blake3:{}\", hash::hash_blake3_to_str(&encoded)))\n}\n\nfn verify_artifact_checksum(manifest: &CacheManifest, archive_path: Option<&Path>) -> Result<()> {\n    let Some(expected) = &manifest.artifact_checksum else {\n        return Ok(());\n    };\n    let archive_path = if manifest.roots.is_empty() {\n        None\n    } else {\n        Some(archive_path.ok_or_else(|| eyre!(\"task cache archive is missing\"))?)\n    };\n    let actual = calculate_artifact_checksum(manifest, archive_path)?;\n    if actual != *expected {\n        bail!(\"task cache artifact checksum mismatch\");\n    }\n    Ok(())\n}\n\npub(crate) fn task_cache_entries(task: &Task, root: &Path) -> Result<Vec<TaskCacheEntry>> {\n    Settings::get().ensure_experimental(\"task artifact caching\")?;\n    let cache_dir = task_cache_dir();\n    if !cache_dir.is_dir() {\n        return Ok(Vec::new());\n    }\n    let identity = task_cache_identity(task, root);\n    let current_key = file::read_to_string(task_cache_state_path(task, root))\n        .ok()\n        .map(|key| key.trim().to_string());\n    let mut entries = Vec::new();\n    for entry in fs::read_dir(&cache_dir)? {\n        let entry = entry?;\n        let manifest_path = entry.path();","sourceCodeStart":922,"sourceCodeEnd":958,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/task/task_cache.rs#L922-L958","documentation":"Before a cache entry is trusted, mise recomputes the artifact checksum (calculate_artifact_checksum over the manifest and archive) and compares it to the expected checksum recorded in the manifest/entry. Any difference aborts the hit, because the archive may be corrupted or tampered with.","triggerScenarios":"verify_artifact_checksum during cache restore: expected checksum exists (or an archive path is required) and calculate_artifact_checksum returns a hash different from the stored one — truncated download/upload, bitrot, or a modified archive file.","commonSituations":"Flaky network during remote cache download; disk corruption on long-lived CI caches; someone re-uploading artifacts without updating the manifest; storage tiers that silently truncate large files.","solutions":["Delete the affected cache entry and rerun the task to regenerate and re-upload a fresh artifact.","Purge the local (or remote) task-artifacts cache if many entries fail.","Check for network/storage layers that corrupt or truncate uploads (proxies, size limits).","Verify clock/cleanup jobs aren't truncating archives mid-write; ensure atomic uploads."],"exampleFix":"// before\nremote artifact downloaded at 90% -> sha256 mismatch\n// after\nrm -rf ~/.cache/mise/task-artifacts && mise run build  # re-download or regenerate intact artifact","handlingStrategy":"retry","validationCode":"const actual = sha256(await fs.readFile(archivePath));\nif (actual !== manifest.artifact.sha256) console.warn('cache entry corrupt; regenerating');","typeGuard":null,"tryCatchPattern":"// retry once after clearing the corrupt entry\ntry { restore(entry) } catch (e) {\n  if (String(e).includes('checksum mismatch')) { cache.delete(entry); regenerateAndReupload(); }\n  else throw e;\n}","preventionTips":["Verify integrity of network/storage layers (proxies, size limits, disk health)","Upload artifacts atomically and never modify an archive in place","Re-upload artifact and manifest together after any change"],"tags":["task-cache","checksum","integrity"],"backgroundTag":"checksum-mismatch","analyzedSha":"533346cc374382b41ec5ff70536252b2e96e725c","analyzedAt":"2026-09-17T13:35:38.149Z","contentChangedAt":"2026-09-17T13:35:38.149Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}