databendlabs/databend · error
Zip type requires additional judgment and use…
Error message
Zip type requires additional judgment and use `decompress_all_zip`
What it means
The decompression codec factory in src/common/compress cannot build a generic streaming decoder for the Zip algorithm: ZIP archives hold multiple named entries and require per-entry handling, so CompressAlgorithm::Zip hits an unreachable!() panic in DecompressCodec::from. The message directs callers to use decompress_all_zip instead, which iterates and decompresses every entry of the archive.
Solutions
- Route Zip inputs to decompress_all_zip before constructing a DecompressCodec
- Check the CompressAlgorithm before calling from() and only build a codec for Gzip/Lzma/Xz/Zlib/Zstd
- Change configuration to a supported streaming algorithm (e.g. gzip, zstd) when per-entry zip semantics are not needed
- Replace the panic with a typed UnsupportedAlgorithm error for clearer diagnostics
Example fix
// before
let codec = DecompressCodec::from(algorithm); // panics when algorithm == Zip
// after
let data = match algorithm {
CompressAlgorithm::Zip => decompress_all_zip(&raw)?,
alg => DecompressCodec::from(alg).decode(&raw)?,
}; Defensive patterns
Strategy: validation
Validate before calling
if algorithm == CompressAlgorithm::Zip {
return decompress_all_zip(&input).map_err(|e| e.into());
} Type guard
fn is_streaming_codec(alg: CompressAlgorithm) -> bool {
!matches!(alg, CompressAlgorithm::Zip)
} Try / catch
match DecompressCodec::try_from(algorithm) {
Ok(codec) => codec.decode(&data)?,
Err(UnsupportedAlgorithm(Zip)) => decompress_all_zip(&data)?,
} Prevention
- Never pass CompressAlgorithm::Zip into the generic codec factory
- Detect .zip inputs (magic bytes PK\x03\x04) and route to decompress_all_zip early
- Document that single-stream codecs exclude Zip in configuration validation
When it happens
Trigger: Constructing a DecompressCodec via From/`from` with CompressAlgorithm::Zip — e.g. a compression algorithm resolved from configuration or file metadata equals Zip and the generic decode path is taken instead of the dedicated zip path.
Common situations: A user configures compression = zip for a stage/stream decoder that only supports single-stream codecs; auto-detection of a .zip upload routes it to the generic decompressor; refactoring code that previously special-cased Zip removed the guard before calling from().
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- Zip type requires additional judgment and use…
- internal error: entered unreachable code
- {}
- Temp table id used up
- Invalid temp table desc
AI-assisted analysis of databendlabs/databend@288d84d76e (2026-09-11).
Data as JSON: /api/errors/5cf7b04aab52920f.
Report an issue: GitHub.
Appendix: source
Thrown at src/common/compress/src/decode.rs:80
/// Decoder for [`CompressAlgorithm::Zlib`]
Zlib(ZlibDecoder),
/// Decoder for [`CompressAlgorithm::Zstd`]
Zstd(ZstdDecoder),
}
impl From<CompressAlgorithm> for DecompressCodec {
fn from(v: CompressAlgorithm) -> Self {
match v {
CompressAlgorithm::Brotli => DecompressCodec::Brotli(Box::new(BrotliDecoder::new())),
CompressAlgorithm::Bz2 => DecompressCodec::Bz2(BzDecoder::new()),
CompressAlgorithm::Deflate => DecompressCodec::Deflate(DeflateDecoder::new()),
CompressAlgorithm::Gzip => DecompressCodec::Gzip(GzipDecoder::new()),
CompressAlgorithm::Lzma => DecompressCodec::Lzma(LzmaDecoder::new()),
CompressAlgorithm::Xz => DecompressCodec::Xz(XzDecoder::new()),
CompressAlgorithm::Zlib => DecompressCodec::Zlib(ZlibDecoder::new()),
CompressAlgorithm::Zstd => DecompressCodec::Zstd(ZstdDecoder::new()),
CompressAlgorithm::Zip => {
unreachable!("Zip type requires additional judgment and use `decompress_all_zip`")
}
}
}
}
impl Decode for DecompressCodec {
fn reinit(&mut self) -> Result<()> {
match self {
DecompressCodec::Brotli(v) => v.reinit(),
DecompressCodec::Bz2(v) => v.reinit(),
DecompressCodec::Deflate(v) => v.reinit(),
DecompressCodec::Gzip(v) => v.reinit(),
DecompressCodec::Lzma(v) => v.reinit(),
DecompressCodec::Xz(v) => v.reinit(),
DecompressCodec::Zlib(v) => v.reinit(),
DecompressCodec::Zstd(v) => v.reinit(),
}
}View on GitHub (pinned to 288d84d76e)