{"record":{"id":"2c9fc9e5e049495d","repo":"astrid-runtime/astrid","slug":"delta-has-trailing-bytes","errorCode":null,"errorMessage":"delta has trailing bytes","messagePattern":"delta has trailing bytes","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/astrid-storage-chunker-evidence/src/sketch.rs","lineNumber":755,"sourceCode":"\n    fn take(&mut self, length: usize) -> Result<&'a [u8]> {\n        let end = self\n            .offset\n            .checked_add(length)\n            .ok_or_else(|| anyhow::anyhow!(\"delta cursor overflow\"))?;\n        let bytes = self\n            .bytes\n            .get(self.offset..end)\n            .ok_or_else(|| anyhow::anyhow!(\"truncated delta\"))?;\n        self.offset = end;\n        Ok(bytes)\n    }\n\n    fn done(self) -> Result<()> {\n        if self.offset == self.bytes.len() {\n            Ok(())\n        } else {\n            bail!(\"delta has trailing bytes\")\n        }\n    }\n}\n\nfn unlimited_context() -> RefineryBatchContext {\n    RefineryBatchContext::new(\n        RefinerySnapshotId::new(ObjectId::new([0; 32])),\n        PlacementEpoch::new(1),\n        RefineryResourceBudget::new(u64::MAX, u128::MAX, u64::MAX, u64::MAX, u64::MAX, u64::MAX),\n        None,\n    )\n}\n\nfn deterministic_random_candidate(\n    target: ObjectId,\n    corpus_kind: CorpusKind,\n    versions: &[Version],\n    target_index: usize,","sourceCodeStart":737,"sourceCodeEnd":773,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-storage-chunker-evidence/src/sketch.rs#L737-L773","documentation":"`DeltaCursor::done` is called at the end of `apply_delta` to assert the cursor consumed exactly the whole input. Leftover bytes after the last operation mean the blob contains unrecognized trailing data — either it was corrupted/appended-to, or it is not a well-formed delta for this decoder.","triggerScenarios":"Calling `apply_delta` on a delta blob with extra bytes appended after the final operation — e.g. concatenated deltas, padding added by a writer, or a blob from a format variant that includes a footer.","commonSituations":"Naive delta concatenation when merging stores; writers that add trailing metadata; partial-overwrite corruption leaving stale bytes.","solutions":["Re-encode the delta cleanly with encode_delta instead of concatenating or appending.","Strip any trailing metadata/footer the producer added before calling apply_delta.","Compare the blob length with the size recorded at encode time to detect appended data.","Investigate the writer that produced the blob for post-hoc writes."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"fn delta_length_recorded(blob: &[u8], expected_len: usize) -> bool {\n    blob.len() == expected_len\n}","typeGuard":null,"tryCatchPattern":"match apply_delta(&base_bytes, &encoded) {\n    Err(e) if e.to_string().contains(\"trailing bytes\") => {\n        eprintln!(\"delta blob has appended data; re-encode cleanly\");\n    },\n    r => r?,\n}","preventionTips":["Never concatenate delta blobs; encode a fresh delta for combined inputs.","Record and compare the encoded length at write time.","Configure writers to emit exact-size blobs with no padding or footers."],"tags":["rust","decoding","delta-encoding","trailing-data"],"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"}