{"record":{"id":"44227c371a257b10","repo":"vectordotdev/vector","slug":"zlib-writer-should-not-fail-to-finish","errorCode":null,"errorMessage":"zlib writer should not fail to finish","messagePattern":"zlib writer should not fail to finish","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/sinks/util/compressor.rs","lineNumber":44,"sourceCode":"            Writer::Zlib(inner) => inner.get_ref().get_ref().get_ref(),\n            Writer::Zstd(inner) => inner.get_ref().get_ref(),\n            Writer::Snappy(inner) => inner.get_ref().get_ref(),\n        }\n    }\n\n    pub fn into_inner(self) -> BytesMut {\n        match self {\n            Writer::Plain(writer) => writer,\n            Writer::Gzip(writer) => writer\n                .into_inner()\n                .expect(\"BufWriter writer should not fail to finish\")\n                .finish()\n                .expect(\"gzip writer should not fail to finish\"),\n            Writer::Zlib(writer) => writer\n                .into_inner()\n                .expect(\"BufWriter writer should not fail to finish\")\n                .finish()\n                .expect(\"zlib writer should not fail to finish\"),\n            Writer::Zstd(writer) => writer\n                .finish()\n                .expect(\"zstd writer should not fail to finish\"),\n            Writer::Snappy(writer) => writer\n                .finish()\n                .expect(\"snappy writer should not fail to finish\"),\n        }\n        .into_inner()\n    }\n\n    pub fn finish(self) -> io::Result<BytesMut> {\n        let buf = match self {\n            Writer::Plain(writer) => writer,\n            Writer::Gzip(writer) => writer.into_inner()?.finish()?,\n            Writer::Zlib(writer) => writer.into_inner()?.finish()?,\n            Writer::Zstd(writer) => writer.finish()?,\n            Writer::Snappy(writer) => writer.finish()?,\n        }","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/vectordotdev/vector/blob/bdb87aeaa4c4ff27c0ba643c1c77b21bf2ef4013/src/sinks/util/compressor.rs#L26-L62","documentation":"A panic assertion on `ZlibEncoder::finish()` in `Writer::into_inner` (compressor.rs). The zlib stream trailer is written into an in-memory `BytesMut` writer that cannot fail, so Vector asserts completion. A panic would mean the in-memory write failed during stream finalization — an internal invariant violation such as allocation failure.","triggerScenarios":"Calling `Writer::into_inner()` with `Compression::Zlib` when `ZlibEncoder::finish` returns Err while finalizing the compressed stream.","commonSituations":"Rare; effectively only under memory pressure while finalizing a zlib-compressed sink payload.","solutions":["Raise process/container memory limits.","Switch to the fallible `Writer::finish()` API which propagates errors as `io::Result`.","File a Vector bug if the panic reproduces without memory pressure."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"let finished = writer.into_inner()?.finish()?; // io::Result propagated, no panic","preventionTips":["Propagate io::Result instead of asserting on zlib stream finalization.","Monitor memory usage of sinks configured with compression: zlib.","Test sink payloads near batch.max_bytes limits to catch growth failures early."],"tags":["rust","compression","zlib","panic"],"backgroundTag":"internal-invariant-violation","analyzedSha":"bdb87aeaa4c4ff27c0ba643c1c77b21bf2ef4013","analyzedAt":"2026-09-16T02:53:35.741Z","contentChangedAt":"2026-09-16T02:53:35.741Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}