astrid-runtime/astrid · error
delta has trailing bytes
Error message
delta has trailing bytes
What it means
`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.
Source
Thrown at crates/astrid-storage-chunker-evidence/src/sketch.rs:755
fn take(&mut self, length: usize) -> Result<&'a [u8]> {
let end = self
.offset
.checked_add(length)
.ok_or_else(|| anyhow::anyhow!("delta cursor overflow"))?;
let bytes = self
.bytes
.get(self.offset..end)
.ok_or_else(|| anyhow::anyhow!("truncated delta"))?;
self.offset = end;
Ok(bytes)
}
fn done(self) -> Result<()> {
if self.offset == self.bytes.len() {
Ok(())
} else {
bail!("delta has trailing bytes")
}
}
}
fn unlimited_context() -> RefineryBatchContext {
RefineryBatchContext::new(
RefinerySnapshotId::new(ObjectId::new([0; 32])),
PlacementEpoch::new(1),
RefineryResourceBudget::new(u64::MAX, u128::MAX, u64::MAX, u64::MAX, u64::MAX, u64::MAX),
None,
)
}
fn deterministic_random_candidate(
target: ObjectId,
corpus_kind: CorpusKind,
versions: &[Version],
target_index: usize,View on GitHub (pinned to affd8760f4)
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.
Defensive patterns
Strategy: validation
Validate before calling
fn delta_length_recorded(blob: &[u8], expected_len: usize) -> bool {
blob.len() == expected_len
} Try / catch
match apply_delta(&base_bytes, &encoded) {
Err(e) if e.to_string().contains("trailing bytes") => {
eprintln!("delta blob has appended data; re-encode cleanly");
},
r => r?,
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: Naive delta concatenation when merging stores; writers that add trailing metadata; partial-overwrite corruption leaving stale bytes.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
Related errors
- unknown delta operation
- delta output length differs from its header
- delta magic mismatch
- encoded evidence delta did not reconstruct its target
- cannot remove capsule authority while an install transaction
AI-assisted analysis of astrid-runtime/astrid@affd8760f4 (2026-09-09).
Data as JSON: /api/errors/2c9fc9e5e049495d.
Report an issue: GitHub.