GitoxideLabs/gitoxide · error
BUG: forgot to implement chunk
Error message
BUG: forgot to implement chunk {:?} What it means
While writing a multi-index (MIDX) file, each planned chunk must have a writer; this panic states a chunk ID was reached for which no write implementation exists — i.e. an internal dispatch gap. It indicates either a corrupt/unknown chunk plan or a chunk type added without implementing its writer.
Solutions
- Upgrade gix-pack so the writer knows all chunk IDs the planner can emit
- Ensure only well-known chunk IDs (from gix_pack::multi_index::chunk::*) are planned
- If triggered by corrupted input idx files, regenerate the multi-index from valid pack files
Example fix
// before
unknown => unreachable!("BUG: forgot to implement chunk {:?}", std::str::from_utf8(&unknown)),
// after
unknown => return Err(Error::Io(gix_hash::io::Error::from(std::io::Error::new(
std::io::ErrorKind::Unsupported,
format!("unknown chunk {:?}", std::str::from_utf8(&unknown)),
)))), Defensive patterns
Strategy: try-catch
Validate before calling
// only plan well-known chunks
const KNOWN: [[u8; 4]; 4] = [
*b"PNAM", *b"OIDF", *b"OIDL", *b"OOFF",
];
assert!(chunks.iter().all(|c| KNOWN.contains(c)), "unknown chunk id in plan"); Try / catch
match multi_index::File::write_from_index_paths(paths, progress, should_interrupt) {
Ok(f) => f,
Err(e) => { log::error!("midx write failed: {e}"); return Err(e.into()); }
} // panics from unknown chunks cannot be caught without catch_unwind Prevention
- Don't construct custom chunk plans; use the library's default planning
- Use matching versions of all gix crates (same lockfile/release)
- Regenerate multi-index files from valid idx inputs produced by git or gix
When it happens
Trigger: Calling `write_from_index_paths` (multi-index generation) with a chunk plan containing a chunk ID other than the known ones (pack names, OID fanout/lookup, large offsets) — typically from internal planning logic or a future/unknown chunk id sneaking into the plan.
Common situations: Using a gix-pack version mismatch where chunk planning emits IDs the writer doesn't know; hand-built chunk lists; midx format evolution introducing new chunks older code can't write.
Related errors
- Should never see other errors than zlib, but got
- ' ' is not a valid configuration key
- Cannot use iter_v1() on index of type
- Cannot use iter_v2() on index of type
- BUG: tries to obtain object id from symbolic target
AI-assisted analysis of GitoxideLabs/gitoxide@e73179060b (2026-09-08).
Data as JSON: /api/errors/1fe54eca8c406334.
Report an issue: GitHub.
Appendix: source
Thrown at gix-pack/src/multi_index/write.rs:221
let mut chunk_write = cf
.into_write(&mut out, bytes_written)
.map_err(gix_hash::io::Error::from)?;
while let Some(chunk_to_write) = chunk_write.next_chunk() {
match chunk_to_write {
multi_index::chunk::index_names::ID => {
multi_index::chunk::index_names::write(&index_filenames_sorted, &mut chunk_write)
}
multi_index::chunk::fanout::ID => multi_index::chunk::fanout::write(&entries, &mut chunk_write),
multi_index::chunk::lookup::ID => multi_index::chunk::lookup::write(&entries, &mut chunk_write),
multi_index::chunk::offsets::ID => {
multi_index::chunk::offsets::write(&entries, num_large_offsets.is_some(), &mut chunk_write)
}
multi_index::chunk::large_offsets::ID => multi_index::chunk::large_offsets::write(
&entries,
num_large_offsets.expect("available if planned"),
&mut chunk_write,
),
unknown => unreachable!("BUG: forgot to implement chunk {:?}", std::str::from_utf8(&unknown)),
}
.map_err(gix_hash::io::Error::from)?;
progress.inc();
if should_interrupt.load(Ordering::Relaxed) {
return Err(Error::Interrupted);
}
}
}
// write trailing checksum
let multi_index_checksum = out.inner.hash.try_finalize().map_err(gix_hash::io::Error::from)?;
out.inner
.inner
.write_all(multi_index_checksum.as_slice())
.map_err(gix_hash::io::Error::from)?;
out.progress.show_throughput(write_start);
Ok(Outcome { multi_index_checksum })View on GitHub (pinned to e73179060b)