{"record":{"id":"eb83e712e0e4a7b4","repo":"jdx/mise","slug":"remote-cache-blob-pack-failed-digest-verification","errorCode":null,"errorMessage":"remote cache blob pack failed digest verification","messagePattern":"remote cache blob pack failed digest verification","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/mise-cache-core/src/lib.rs","lineNumber":853,"sourceCode":"\n        let path = directory.path().join(blobs.len().to_string());\n        let mut output = tokio::fs::File::create(&path).await?;\n        let mut remaining = digest.size;\n        let mut buffer = [0_u8; 64 * 1024];\n        while remaining > 0 {\n            let limit = usize::try_from(remaining.min(buffer.len() as u64)).unwrap();\n            let count = reader.read(&mut buffer[..limit]).await?;\n            if count == 0 {\n                bail!(\"remote cache blob pack ended before a blob was complete\");\n            }\n            output.write_all(&buffer[..count]).await?;\n            hasher.update(&buffer[..count]);\n            remaining -= count as u64;\n        }\n        output.flush().await?;\n        drop(output);\n        if !hasher.matches(&digest.hash) {\n            bail!(\"remote cache blob pack failed digest verification\");\n        }\n        blobs.push((digest, path));\n    }\n    let blob_count = blobs.len().try_into().unwrap_or(u64::MAX);\n    let metadata = metadata.validate(BlobPackResponseStats {\n        blob_count,\n        payload_bytes,\n        framed_bytes,\n    })?;\n    Ok(DownloadedBlobPack {\n        directory,\n        blobs,\n        metadata,\n    })\n}\n\nenum BlobPackHasher {\n    Blake3(Box<blake3::Hasher>),","sourceCodeStart":835,"sourceCodeEnd":871,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/crates/mise-cache-core/src/lib.rs#L835-L871","documentation":"After fully writing a blob from the remote cache pack to disk, the client hashes the streamed bytes and compares against the digest sent by the server. A mismatch means the payload content differs from what the pack promised, so the blob is rejected. This protects against corruption and tampering.","triggerScenarios":"hasher.matches(&digest.hash) is false after unpacking a blob — streamed content hash does not equal the digest hash declared in the pack framing.","commonSituations":"Bit-rot or disk corruption on the server, corrupted transfer, MITM modification on plain-HTTP cache connections, server storing wrong bytes under a digest.","solutions":["Retry the fetch; if it fails consistently the server copy is corrupt and must be repopulated","Force the server to re-upload/rebuild the affected cache entry","Use HTTPS for the cache URL so payloads cannot be modified in transit","Verify no storage layer (NFS/S3 sync tools) is silently corrupting blob files"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"match unpack_blob_pack(...).await {\n    Err(e) if e.to_string().contains(\"digest verification\") => {\n        eprintln!(\"cache entry corrupt; refetching from origin\");\n        // evict entry and repopulate\n    }\n    other => other,\n}","preventionTips":["Use HTTPS so payloads cannot be modified in transit","Monitor server storage health (fsck, S3 checksums)","Replicate cache entries across regions to survive local corruption"],"tags":["remote-cache","integrity","checksum"],"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"}