{"record":{"id":"6127a98956bbfb97","repo":"GitoxideLabs/gitoxide","slug":"should-never-see-other-errors-than-zlib-but-got-6127a9","errorCode":null,"errorMessage":"Should never see other errors than zlib, but got {:?}","messagePattern":"Should never see other errors than zlib, but got (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"gix-pack/src/data/output/entry/mod.rs","lineNumber":157,"sourceCode":"    /// deflating it with `compression`.\n    ///\n    /// Note that `git` compresses pack entries with the level configured with `pack.compression`,\n    /// whose default is [`Compression::DEFAULT`](gix_zlib::Compression::DEFAULT).\n    pub fn from_data(\n        count: &output::Count,\n        obj: &gix_object::Data<'_>,\n        compression: gix_zlib::Compression,\n    ) -> Result<Self, Error> {\n        Ok(output::Entry {\n            id: count.id.to_owned(),\n            kind: Kind::Base(obj.kind),\n            decompressed_size: obj.data.len(),\n            compressed_data: {\n                let mut out = gix_zlib::stream::deflate::Write::new(Vec::new(), compression);\n                if let Err(err) = std::io::copy(&mut &*obj.data, &mut out) {\n                    match err.kind() {\n                        std::io::ErrorKind::Other => return Err(Error::ZlibDeflate(err)),\n                        err => unreachable!(\"Should never see other errors than zlib, but got {:?}\", err),\n                    }\n                }\n                out.flush()?;\n                out.into_inner()\n            },\n        })\n    }\n\n    /// Transform ourselves into a pack entry header which can be written into a pack of `version`.\n    ///\n    /// `index_to_pack(object_index) -> pack_offset` is a function to convert the base object's index into\n    /// the input object array (if each object is numbered) to an offset into the pack.\n    /// This information is known to the one calling the method.\n    pub fn to_entry_header(\n        &self,\n        _version: data::Version,\n        index_to_base_distance: impl FnOnce(usize) -> u64,\n    ) -> data::entry::Header {","sourceCodeStart":139,"sourceCodeEnd":175,"githubUrl":"https://github.com/GitoxideLabs/gitoxide/blob/e73179060badf27222d790981fac3f84c1830a7e/gix-pack/src/data/output/entry/mod.rs#L139-L175","documentation":"This panic fires while an in-memory object's data is being zlib-deflated for a pack entry. The code assumes any I/O error from `std::io::copy` over a `&[u8]` source must carry `ErrorKind::Other`, which the zlib encoder uses for its failures; anything else is considered impossible for a pure in-memory slice and panics with an unreachable.","triggerScenarios":"Calling `output::Entry::from(&obj)` (pack entry construction during pack writing) while the underlying zlib deflate stream returns an io::Error whose kind is not `Other` — e.g. an io error injected by a custom writer wrapper or an unexpected error propagated from the Vec sink.","commonSituations":"Rare in practice: writing packs with a gix version whose zlib backend surfaces errors with different ErrorKinds, or wrapping/intercepting writers; virtually never hit with plain in-memory data.","solutions":["Update gix-pack/gix-zlib so zlib errors always map to ErrorKind::Other, or upgrade the crate","Capture the panic message and report it upstream with the offending object data","Work around by compressing via `gix_zlib::stream::deflate::Write` yourself and handling all error kinds explicitly"],"exampleFix":"// before\nerr => unreachable!(\"Should never see other errors than zlib, but got {:?}\", err),\n// after\nerr => return Err(Error::ZlibDeflate(std::io::Error::new(err.kind(), err))),","handlingStrategy":"try-catch","validationCode":"// ensure data is an in-memory slice before building the entry\ndebug_assert!(obj.data.is_empty() || compression.level().is_some(), \"compression level must be valid\");","typeGuard":"fn is_io_other(err: &std::io::Error) -> bool { err.kind() == std::io::ErrorKind::Other }","tryCatchPattern":"match result {\n    Ok(entry) => entry,\n    Err(e) => { log::error!(\"pack entry deflate failed: {e}\"); return Err(e); }\n} // plus catch_unwind if calling from FFI or a long-lived writer","preventionTips":["Keep gix-zlib and gix-pack versions in sync from the same release","Don't wrap the object data source in custom io layers that emit non-Other errors","Treat any panic here as a library bug and file it with the gix maintainers"],"tags":["rust","zlib","pack-write","panic"],"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-16T04:17:20.429Z"}