{"record":{"id":"8239ac68dbc69ff7","repo":"GitoxideLabs/gitoxide","slug":"if-you-see-this-the-object-database-is-correct-as","errorCode":null,"errorMessage":"if you see this the object database is correct as a delta refers to a non-existing object","messagePattern":"if you see this the object database is correct as a delta refers to a non-existing object","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"gix-pack/src/data/output/bytes.rs","lineNumber":106,"sourceCode":"        if let Some((version, num_entries)) = self.header_info.take() {\n            let header_bytes = crate::data::header::encode(version, num_entries);\n            self.output\n                .write_all(&header_bytes[..])\n                .map_err(gix_hash::io::Error::from)?;\n            self.written += header_bytes.len() as u64;\n        }\n        match self.input.next() {\n            Some(entries) => {\n                for entry in entries.map_err(Error::Input)? {\n                    if entry.is_invalid() {\n                        self.pack_offsets_and_validity.push((0, false));\n                        continue;\n                    }\n                    self.pack_offsets_and_validity.push((self.written, true));\n                    let header = entry.to_entry_header(self.entry_version, |index| {\n                        let (base_offset, is_valid_object) = self.pack_offsets_and_validity[index];\n                        if !is_valid_object {\n                            unreachable!(\"if you see this the object database is correct as a delta refers to a non-existing object\")\n                        }\n                        self.written - base_offset\n                    });\n                    self.written += header\n                        .write_to(entry.decompressed_size as u64, &mut self.output)\n                        .map_err(gix_hash::io::Error::from)? as u64;\n                    self.written += std::io::copy(&mut &*entry.compressed_data, &mut self.output)\n                        .map_err(gix_hash::io::Error::from)?;\n                }\n            }\n            None => {\n                let digest = self\n                    .output\n                    .hash\n                    .clone()\n                    .try_finalize()\n                    .map_err(gix_hash::io::Error::from)?;\n                self.output","sourceCodeStart":88,"sourceCodeEnd":124,"githubUrl":"https://github.com/GitoxideLabs/gitoxide/blob/e73179060badf27222d790981fac3f84c1830a7e/gix-pack/src/data/output/bytes.rs#L88-L124","documentation":"This `unreachable!()` fires in the pack writer's `next_inner` (gix-pack `data/output/bytes.rs`) while writing a delta entry header: offsets of bases are only tracked for entries marked valid, and an invalid base slot means the delta referred to an object that does not exist in the object database. The authors assume counts were validated against the ODB beforehand, so reaching this indicates the object database is inconsistent (a delta whose base object is missing).","triggerScenarios":"Streaming a pack via the bytes output iterator when a DELTAFIED entry resolves its base through `pack_offsets_and_validity` and finds `is_valid_object == false` — i.e. the source ODB contained a delta referencing a non-existent (or pruned/corrupted) base object.","commonSituations":"Packing from a corrupted or manually-tampered object database, thin-pack assumptions violated (base objects not included), interrupted repacks that left dangling deltas, or bugs in custom ODB implementations that report objects as existing when their bases don't.","solutions":["Run `git fsck --full` (or `gix`-based integrity checks) on the source repository to find and repair broken object chains.","Ensure thin packs are disabled or that base objects are included when packing (verify the `Count` objects were fully resolved before streaming).","Re-generate the pack from a healthy source (e.g. clone/fetch anew) instead of repacking the corrupted ODB.","Report to gitoxide maintainers if the ODB is verified correct, since the code treats this state as impossible."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Verify object database integrity before packing\nuse std::process::Command;\nlet status = Command::new(\"git\").args([\"fsck\", \"--full\"]).status()?;\nif !status.success() {\n    return Err(anyhow!(\"object database is corrupted; repair before packing\"));\n}","typeGuard":null,"tryCatchPattern":"// Catch the panic at the pack-stream boundary\nstd::panic::catch_unwind(AssertUnwindSafe(|| pack_bytes_iter.next()))\n    .map_err(|p| anyhow!(\"delta base missing during pack write: {:?}\", p))?;","preventionTips":["Run `git fsck` regularly on repositories you repack programmatically.","Never prune or delete objects from an ODB while pack writing is in progress.","Avoid packing repositories that were copied mid-gc or interrupted during repack.","Prefer thin packs only when you control the base objects being sent."],"tags":["panic","pack","delta","object-database","corruption","internal-invariant"],"backgroundTag":"resource-not-found","analyzedSha":"e73179060badf27222d790981fac3f84c1830a7e","analyzedAt":"2026-09-08T11:26:50.865Z","contentChangedAt":"2026-09-08T11:26:50.865Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}