{"record":{"id":"157c05d941fd9db6","repo":"pola-rs/polars","slug":"activate-decompress-feature","errorCode":null,"errorMessage":"activate 'decompress' feature","messagePattern":"activate 'decompress' feature","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/polars-io/src/utils/compression.rs","lineNumber":108,"sourceCode":"    pub fn try_new(slice: Buffer<u8>) -> PolarsResult<Self> {\n        let algo = SupportedCompression::check(&slice);\n\n        Ok(match algo {\n            None => CompressedReader::Uncompressed { slice, offset: 0 },\n            #[cfg(feature = \"decompress\")]\n            Some(SupportedCompression::GZIP) => {\n                CompressedReader::Gzip(flate2::bufread::MultiGzDecoder::new(Cursor::new(slice)))\n            },\n            #[cfg(feature = \"decompress\")]\n            Some(SupportedCompression::ZLIB) => {\n                CompressedReader::Zlib(flate2::bufread::ZlibDecoder::new(Cursor::new(slice)))\n            },\n            #[cfg(feature = \"decompress\")]\n            Some(SupportedCompression::ZSTD) => {\n                CompressedReader::Zstd(zstd::Decoder::with_buffer(Cursor::new(slice))?)\n            },\n            #[cfg(not(feature = \"decompress\"))]\n            _ => panic!(\"activate 'decompress' feature\"),\n        })\n    }\n\n    pub fn is_compressed(&self) -> bool {\n        !matches!(&self, CompressedReader::Uncompressed { .. })\n    }\n\n    pub const fn initial_read_size() -> usize {\n        // We don't want to read too much at the beginning to keep decompression to a minimum if for\n        // example only the schema is needed or a slice op is used. Keep in sync with\n        // `ideal_read_size` so that `initial_read_size * N * 4 == ideal_read_size`.\n        32 * 1024\n    }\n\n    pub const fn ideal_read_size() -> usize {\n        // Somewhat conservative guess for L2 size, which performs the best on most machines and is\n        // nearly always core exclusive. The loss of going larger and accidentally hitting L3 is not\n        // recouped by amortizing the block processing cost even further.","sourceCodeStart":90,"sourceCodeEnd":126,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/crates/polars-io/src/utils/compression.rs#L90-L126","documentation":"try_new for a compressed reader panics when the input is zstd-compressed (or any compression other than the always-supported ones) and the 'decompress' feature is not enabled. The build lacks the decompression backends, so it cannot handle this input and deliberately aborts.","triggerScenarios":"Constructing CompressedReader::try_new from a buffer whose detected compression is ZSTD (or another decompress-gated codec) on a build without feature = \"decompress\".","commonSituations":"Reading .zst-compressed CSV/IPC files with default polars features; minimal Cargo feature sets that omit decompress; upgrading and forgetting to re-add the feature.","solutions":["Enable the decompress feature: polars = { features = [\"decompress\"], ... }.","Pre-decompress the file yourself (e.g. zstd -d) and feed plain bytes.","If reading through higher-level APIs, check which feature they need (csv/json/ipc with 'decompress')."],"exampleFix":"// before\npolars = { version = \"0.46\", features = [\"csv\"] }\n// after\npolars = { version = \"0.46\", features = [\"csv\", \"decompress\"] }","handlingStrategy":"validation","validationCode":"fn needs_decompress(path: &str) -> bool {\n    path.ends_with(\".zst\") || path.ends_with(\".zstd\")\n}\nassert!(!needs_decompress(path), \"enable polars feature 'decompress' for zstd inputs\");","typeGuard":null,"tryCatchPattern":"// It's a panic; gate at startup/feature time, not at call time\n#[cfg(not(feature = \"polars/decompress\"))]\ncompile_error!(\"this build reads compressed files; enable polars 'decompress' feature\");","preventionTips":["Enable the 'decompress' feature whenever inputs may be zstd-compressed","Sniff file extensions/magic bytes before choosing a read path","Document required polars features next to the data-ingestion code"],"tags":["compression","feature-flag","zstd","panic"],"backgroundTag":"feature-not-enabled","analyzedSha":"fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e","analyzedAt":"2026-09-18T22:14:11.667Z","contentChangedAt":"2026-09-18T22:14:11.667Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}