{"record":{"id":"67aad5020e2c53ca","repo":"GitoxideLabs/gitoxide","slug":"should-never-see-other-errors-than-zlib-but-got","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/input/entry.rs","lineNumber":64,"sourceCode":"}\n\nfn to_header(kind: gix_object::Kind) -> Header {\n    use gix_object::Kind::*;\n    match kind {\n        Tree => Header::Tree,\n        Blob => Header::Blob,\n        Commit => Header::Commit,\n        Tag => Header::Tag,\n    }\n}\n\nfn compress_data(obj: &gix_object::Data<'_>, compression: gix_zlib::Compression) -> Result<Vec<u8>, input::Error> {\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(input::Error::Io(err.into())),\n            err => {\n                unreachable!(\"Should never see other errors than zlib, but got {:?}\", err)\n            }\n        }\n    }\n    out.flush().expect(\"zlib flush should never fail\");\n    Ok(out.into_inner())\n}\n","sourceCodeStart":46,"sourceCodeEnd":71,"githubUrl":"https://github.com/GitoxideLabs/gitoxide/blob/e73179060badf27222d790981fac3f84c1830a7e/gix-pack/src/data/input/entry.rs#L46-L71","documentation":"This is a Rust `unreachable!()` panic in `compress_data` (gix-pack). When deflating an object with zlib, the code maps `std::io::ErrorKind::Other` to a normal I/O error, and treats any other io::ErrorKind as impossible because the zlib deflate stream should only ever surface `Other`-kind errors. If the zlib backend ever returns a differently-classified I/O error, the library authors consider it a bug in the zlib integration and intentionally panic.","triggerScenarios":"Packing a pack entry via `from_data_obj`/`compress_data` when `std::io::copy` into the zlib `deflate::Write` fails with an io::Error whose kind is not `ErrorKind::Other` (e.g. a platform-level error surfaced by the zlib stream wrapper).","commonSituations":"A bug or unexpected behavior in the zlib compression backend (gix-zlib / flate2), resource exhaustion (OOM during deflate) that the backend classifies under a non-Other kind, or running with an unusual zlib feature-toggle combination. Practically almost never hit by users; indicates a library-level defect when it happens.","solutions":["Update gix-pack, gix-zlib and flate2 to the latest versions (the panic indicates an unhandled zlib error classification that may already be fixed).","Capture the full panic message including the `{:?}` of the error and file an issue against gitoxide with the error kind.","As a workaround, reduce memory pressure / retry the pack operation; if reproducible, try a different zlib feature (e.g. zlib-ng vs default) to see if the backend is the cause."],"exampleFix":"// library-side before (panics)\nerr => {\n    unreachable!(\"Should never see other errors than zlib, but got {:?}\", err)\n}\n// library-side after (propagates instead of panicking)\nerr => {\n    return Err(input::Error::Io(err.into()))\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// Rust: panic cannot be caught without catch_unwind; wrap the whole pack operation\nlet result = std::panic::catch_unwind(|| pack_writer.write_stream(...));\nmatch result {\n    Ok(inner) => inner?,\n    Err(panic) => return Err(anyhow!(\"zlib compression panicked: {:?}\", panic)),\n}","preventionTips":["Keep gix-zlib/flate2 and gitoxide crates on the same, current versions.","Treat any occurrence as a library bug and report it with the io::ErrorKind from the panic message.","Monitor memory pressure when compressing large objects."],"tags":["panic","zlib","compression","internal-invariant","rust"],"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"}