{"record":{"id":"2d215b665d6c39b9","repo":"vectordotdev/vector","slug":"snappy-writer-should-not-fail-to-finish","errorCode":null,"errorMessage":"snappy writer should not fail to finish","messagePattern":"snappy writer should not fail to finish","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/sinks/util/compressor.rs","lineNumber":50,"sourceCode":"    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        }\n        .into_inner();\n\n        Ok(buf)\n    }\n}\n","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/vectordotdev/vector/blob/bdb87aeaa4c4ff27c0ba643c1c77b21bf2ef4013/src/sinks/util/compressor.rs#L32-L68","documentation":"This panic fires when a Snappy encoder's `finish()` returns an error while flushing the compressed stream in `Compressor::into_inner()`. Snappy's streaming encoder only fails on internal stream-state corruption (e.g. a previous write to the underlying writer failed or the buffer was misused), which the sink treats as an unrecoverable invariant breach rather than an expected I/O condition.","triggerScenarios":"Calling `Compressor::into_inner()` (or `finish()`) on a compressor built with `Compression::Snappy` whose internal `SnappyEncoder` reports an error when finalizing the frame stream.","commonSituations":"Almost never hit in practice; would surface during sink shutdown/batch flush if the underlying BytesMut writer was already in a bad state, or after an upstream bug corrupted the encoder.","solutions":["Report this as a bug to Vector with the batch/config that triggered it; this is an internal invariant.","Check for earlier logged I/O errors in the same sink task that may have left the encoder in a bad state.","As a workaround, switch the sink's compression to gzip/zstd, which report finalize errors via Result paths."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// Panics are not catchable in normal Rust; guard at the process level.\nstd::panic::catch_unwind(|| compressor.into_inner())","preventionTips":["Prefer compression codecs that surface errors via Result (gzip, zstd).","Monitor for prior I/O errors in the sink that may corrupt encoder state.","Pin a stable, tested Vector release."],"tags":["rust","compression","snappy","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"}