{"record":{"id":"138960ad7b56457f","repo":"astrid-runtime/astrid","slug":"delta-magic-mismatch","errorCode":null,"errorMessage":"delta magic mismatch","messagePattern":"delta magic mismatch","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/astrid-storage-chunker-evidence/src/sketch.rs","lineNumber":715,"sourceCode":"    }\n    Ok(output)\n}\n\nstruct DeltaCursor<'a> {\n    bytes: &'a [u8],\n    offset: usize,\n}\n\nimpl<'a> DeltaCursor<'a> {\n    const fn new(bytes: &'a [u8]) -> Self {\n        Self { bytes, offset: 0 }\n    }\n\n    fn expect(&mut self, expected: &[u8]) -> Result<()> {\n        if self.take(expected.len())? == expected {\n            Ok(())\n        } else {\n            bail!(\"delta magic mismatch\")\n        }\n    }\n\n    fn skip(&mut self, length: usize) -> Result<()> {\n        self.take(length).map(|_| ())\n    }\n\n    fn byte(&mut self) -> Result<u8> {\n        self.take(1)?\n            .first()\n            .copied()\n            .ok_or_else(|| anyhow::anyhow!(\"truncated delta byte\"))\n    }\n\n    fn u64(&mut self) -> Result<u64> {\n        Ok(u64::from_le_bytes(\n            self.take(8)?\n                .try_into()","sourceCodeStart":697,"sourceCodeEnd":733,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-storage-chunker-evidence/src/sketch.rs#L697-L733","documentation":"`DeltaCursor::expect` consumes `expected.len()` bytes and compares them to an expected literal (e.g. the delta format's magic prefix). Any difference bails with this error, meaning the input is not a delta blob in the expected format — the decoder refuses to parse unrecognizable bytes.","triggerScenarios":"Calling `apply_delta` with bytes that do not begin with the expected delta magic/sig — feeding a full file, a JSON record, an empty buffer, or a delta from a different format version into the decoder.","commonSituations":"Wrong blob fetched from the object store; format version change altering the magic; file corruption overwriting the header.","solutions":["Verify the input is the output of encode_delta (or an equivalent stored delta), not raw file content.","Check the first bytes of the blob against the expected magic to identify what was actually passed.","Re-encode or re-store the delta if the blob is corrupted.","If the magic changed across versions, migrate old deltas before decoding."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const DELTA_MAGIC: &[u8] = b\"ASTRD\";\nfn has_delta_magic(bytes: &[u8]) -> bool {\n    bytes.starts_with(DELTA_MAGIC)\n}","typeGuard":"fn is_delta_blob(bytes: &[u8]) -> bool {\n    bytes.len() > 5 && bytes.starts_with(b\"ASTRD\")\n}","tryCatchPattern":"if !is_delta_blob(&blob) {\n    eprintln!(\"refusing to decode: not a delta blob (bad magic)\");\n} else {\n    apply_delta(&base_bytes, &blob)?;\n}","preventionTips":["Check magic bytes before invoking apply_delta.","Fetch deltas via a typed accessor rather than raw object-store reads.","Log the first bytes of any blob that fails the magic check to identify its true format."],"tags":["rust","decoding","delta-encoding","magic-bytes"],"backgroundTag":"invalid-argument-format","analyzedSha":"affd8760f44190dbdfbec23403f4c4b642c33112","analyzedAt":"2026-09-09T21:28:12.402Z","contentChangedAt":"2026-09-09T21:28:12.402Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}