{"record":{"id":"4c543dbf0db91792","repo":"GitoxideLabs/gitoxide","slug":"always-valid-for-non-refs","errorCode":null,"errorMessage":"always valid for non-refs","messagePattern":"always valid for non-refs","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"gix-pack/src/data/file/decode/header.rs","lineNumber":66,"sourceCode":"    /// For delta entries, this only probes the initial delta header bytes to determine the result\n    /// object size. It can reject streams that end or overflow within that probe, but it does not\n    /// fully validate that the compressed stream produces exactly the decompressed size declared in\n    /// the pack entry header. Use [`File::decode_entry()`][crate::data::File::decode_entry()] when\n    /// callers need that full validation.\n    pub fn decode_header(\n        &self,\n        mut entry: data::Entry,\n        inflate: &mut gix_zlib::Inflate,\n        resolve: &dyn Fn(&gix_hash::oid) -> Option<ResolvedBase>,\n    ) -> Result<Outcome, Error> {\n        use crate::data::entry::Header::*;\n        let mut num_deltas = 0;\n        let mut first_delta_decompressed_size = None::<u64>;\n        loop {\n            match entry.header {\n                Tree | Blob | Commit | Tag => {\n                    return Ok(Outcome {\n                        kind: entry.header.as_kind().expect(\"always valid for non-refs\"),\n                        object_size: first_delta_decompressed_size.unwrap_or(entry.decompressed_size),\n                        num_deltas,\n                    });\n                }\n                OfsDelta { base_distance } => {\n                    num_deltas += 1;\n                    if first_delta_decompressed_size.is_none() {\n                        first_delta_decompressed_size = Some(self.decode_delta_object_size(inflate, &entry)?);\n                    }\n                    entry = self.entry(entry.checked_base_pack_offset(base_distance).ok_or(\n                        crate::data::entry::decode::Error::Corrupt {\n                            message: \"an ofs-delta base distance pointing before pack start\",\n                        },\n                    )?)?;\n                }\n                RefDelta { base_id } => {\n                    num_deltas += 1;\n                    if first_delta_decompressed_size.is_none() {","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/GitoxideLabs/gitoxide/blob/e73179060badf27222d790981fac3f84c1830a7e/gix-pack/src/data/file/decode/header.rs#L48-L84","documentation":"A `expect()` panic in the public pack entry header decoding (`Outcome` construction). The loop returns an `Outcome` only for non-delta headers (Tree/Blob/Commit/Tag), and `as_kind()` is `Some` exactly for those, so the conversion cannot fail. Failure would mean a delta header reached a non-delta branch.","triggerScenarios":"Calling pack entry header decoding (e.g. `gix_pack::data::entry::Header` Outcome computation) — the panic fires only if header matching logic regresses, e.g. after a version change or code modification.","commonSituations":"gix-pack development, fuzzing of pack entry headers with mutated bytes, or mismatched gix crate versions.","solutions":["Keep all gix-* crates at the same version (use the workspace-provided version pins)","Update gix-pack if a header-decoding fix was released","Report a bug with the offending pack bytes"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"let r = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| header.to_outcome()));\nif r.is_err() { eprintln!(\"pack header invariant violated\"); }","preventionTips":["Do not mutate pack entry bytes before header decoding","Keep all gix crates at the same workspace version","Report mutated-header fuzz crashes upstream"],"tags":["rust","panic","internal-invariant","gix-pack","pack-header"],"backgroundTag":"internal-invariant-violation","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"}