GitoxideLabs/gitoxide · error
OFS_DELTA base distance
Error message
OFS_DELTA base distance {base_distance} is invalid for pack offset {pack_offset} What it means
When resolving pack entries by offset, gix-pack validates each OFS_DELTA entry: the base distance must resolve to a valid base pack offset relative to the delta's own offset (`Header::verified_base_pack_offset`). If verification fails, the data is structurally inconsistent and iteration aborts with an `InvalidData` io error wrapped as `Error::Io` with the message 'invalid OFS_DELTA base distance'.
Solutions
- Verify the pack's integrity (trailer SHA/checksum) and re-fetch or re-clone the repository if it fails.
- Run `gix pack` verify/index operations on the pack to locate the corrupt entry.
- If handling untrusted packs, catch the error and reject the pack instead of panicking or proceeding.
Defensive patterns
Strategy: try-catch
Try / catch
match pack_file::iter::FromOffsets::new(...) {
Err(e) => /* reject the pack: check e for 'invalid OFS_DELTA base distance' and verify the pack checksum */,
ok => /* proceed */,
} Prevention
- Verify pack checksums before delta iteration.
- Re-fetch or regenerate packs that fail structural validation.
- Never iterate raw pack bytes at hand-computed offsets; use the crate's parsed headers.
When it happens
Trigger: Iterating entries via `gix_pack::data::File::stream_from`/offset iteration (from_offsets) over a pack containing an OFS_DELTA whose encoded distance points before the start of the pack or is otherwise impossible.
Common situations: Corrupted or truncated packfiles on disk; manually edited or fuzzed pack data; reading bytes at a wrong offset so a delta header is misparsed.
Related errors
- BUG: pack now is smaller than all previously seen entries
- in-bound distance of deltas
- if you see this the object database is correct as a delta…
- At least one object couldn't be looked up even though it…
- could not read reference
AI-assisted analysis of GitoxideLabs/gitoxide@e73179060b (2026-09-08).
Data as JSON: /api/errors/bd4c1a76746aff8d.
Report an issue: GitHub.
Appendix: source
Thrown at gix-pack/src/cache/delta/from_offsets.rs:110
use crate::data::entry::Header::*;
match entry.header {
Tree | Blob | Commit | Tag => {
tree.add_root(pack_offset, data)?;
}
RefDelta { base_id } => {
resolve_in_pack_id(base_id.as_ref())
.ok_or(Error::UnresolvedRefDelta { id: base_id })
.and_then(|base_pack_offset| {
tree.add_child(base_pack_offset, pack_offset, data).map_err(Into::into)
})?;
}
OfsDelta { base_distance } => {
let Some(base_pack_offset) =
crate::data::entry::Header::verified_base_pack_offset(pack_offset, base_distance)
else {
return Err(Error::Io {
source: io::Error::new(
io::ErrorKind::InvalidData,
format!(
"OFS_DELTA base distance {base_distance} is invalid for pack offset {pack_offset}"
),
),
message: "invalid OFS_DELTA base distance",
});
};
tree.add_child(base_pack_offset, pack_offset, data)?;
}
}
progress.inc();
if idx % 10_000 == 0 && should_interrupt.load(Ordering::SeqCst) {
return Err(Error::Interrupted);
}
}
progress.show_throughput(then);View on GitHub (pinned to e73179060b)