{"record":{"id":"0f5514586093626e","repo":"astrid-runtime/astrid","slug":"unknown-delta-operation","errorCode":null,"errorMessage":"unknown delta operation","messagePattern":"unknown delta operation","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/astrid-storage-chunker-evidence/src/sketch.rs","lineNumber":691,"sourceCode":"    let mut output = Vec::with_capacity(usize::try_from(logical_bytes)?);\n    for _ in 0..operation_count {\n        match cursor.byte()? {\n            0 => {\n                let offset = usize::try_from(cursor.u64()?)?;\n                let length = usize::try_from(cursor.u64()?)?;\n                let end = offset\n                    .checked_add(length)\n                    .ok_or_else(|| anyhow::anyhow!(\"delta copy range overflow\"))?;\n                output.extend_from_slice(\n                    base.get(offset..end)\n                        .ok_or_else(|| anyhow::anyhow!(\"delta copy is outside its base\"))?,\n                );\n            },\n            1 => {\n                let length = usize::try_from(cursor.u64()?)?;\n                output.extend_from_slice(cursor.take(length)?);\n            },\n            _ => bail!(\"unknown delta operation\"),\n        }\n    }\n    cursor.done()?;\n    if output.len() != usize::try_from(logical_bytes)? {\n        bail!(\"delta output length differs from its header\");\n    }\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    }","sourceCodeStart":673,"sourceCodeEnd":709,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-storage-chunker-evidence/src/sketch.rs#L673-L709","documentation":"`apply_delta` decodes an encoded delta stream whose operations are tagged by a leading byte: 0 = Copy, 1 = Add. Any other op tag means the byte stream is not a delta this decoder understands — truncated/mangled data, wrong format version, or bytes that are not a delta at all were fed to the decoder.","triggerScenarios":"Calling `apply_delta` (directly or via `delta_size`) with an encoded blob whose operation tag byte is neither 0 nor 1 — e.g. passing a delta produced by a newer encoder version with additional op codes, or arbitrary/corrupted bytes.","commonSituations":"Version skew between encoder and decoder after a format upgrade; truncated delta files; accidentally decoding the wrong blob (e.g. a full file instead of a delta).","solutions":["Confirm the encoded blob came from the matching `encode_delta` version; re-encode with the current library version.","Check for truncation/corruption of the stored delta bytes (compare length with the recorded size).","Ensure you're passing the delta blob, not a full file or metadata record, to apply_delta.","If new op codes are expected, extend apply_delta's match to decode them."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"fn looks_like_delta(bytes: &[u8]) -> bool {\n    // every op must start with tag 0 or 1; at minimum verify the magic header\n    bytes.starts_with(b\"ASTRD\")\n}","typeGuard":"fn is_known_op_tag(tag: u8) -> bool {\n    matches!(tag, 0 | 1)\n}","tryCatchPattern":"match apply_delta(&base_bytes, &encoded) {\n    Err(e) if e.to_string().contains(\"unknown delta operation\") => {\n        eprintln!(\"delta format version mismatch: re-encode with current version\");\n    },\n    r => r?,\n}","preventionTips":["Pin encoder and decoder to the same library version.","Check the magic header before decoding any stored blob.","Store a format-version byte alongside deltas and branch on it before decoding."],"tags":["rust","decoding","delta-encoding","format-version"],"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"}