{"record":{"id":"92e9ea41366acfbe","repo":"quickwit-oss/tantivy","slug":"zstd-compression-feature-is-not-enabled","errorCode":null,"errorMessage":"zstd-compression feature is not enabled","messagePattern":"zstd-compression feature is not enabled","errorType":"exception","errorClass":"io::Error","httpStatus":null,"severity":"error","filePath":"sstable/src/block_reader.rs","lineNumber":120,"sourceCode":"                return Err(io::Error::new(\n                    io::ErrorKind::UnexpectedEof,\n                    \"failed to read block content\",\n                ));\n            }\n            if compress == 1 {\n                #[cfg(feature = \"zstd-compression\")]\n                {\n                    let required_capacity =\n                        Decompressor::upper_bound(&self.reader[..block_len]).unwrap_or(1024 * 1024);\n                    self.buffer.reserve(required_capacity);\n                    Decompressor::new()?\n                        .decompress_to_buffer(&self.reader[..block_len], &mut self.buffer)?;\n\n                    self.reader.advance(block_len);\n                }\n\n                if cfg!(not(feature = \"zstd-compression\")) {\n                    return Err(io::Error::new(\n                        io::ErrorKind::Unsupported,\n                        \"zstd-compression feature is not enabled\",\n                    ));\n                }\n            } else {\n                self.buffer.resize(block_len, 0u8);\n                self.reader.read_exact(&mut self.buffer[..])?;\n            }\n\n            return Ok(true);\n        }\n    }\n\n    #[inline(always)]\n    pub fn offset(&self) -> usize {\n        self.offset\n    }\n","sourceCodeStart":102,"sourceCodeEnd":138,"githubUrl":"https://github.com/quickwit-oss/tantivy/blob/b5d8deb80c26924e6b007a5b1a7630f35ca64de4/sstable/src/block_reader.rs#L102-L138","documentation":"This is an io::Error of kind Unsupported thrown while decompressing an SSTable block: the block's compression format requires zstd, but the crate was compiled without the `zstd-compression` feature enabled. The feature flag gates the zstd codec, so blocks written with zstd cannot be decoded and reading fails instead of silently returning garbage. It is raised in read_block when cfg!(not(feature = \"zstd-compression\")) is true.","triggerScenarios":"Reading (read_block / iterating a segment) an SSTable whose block header declares zstd compression while the tantivy/sstable crate was built without the `zstd-compression` cargo feature; typically after switching to a default-features=false dependency or moving an index built by a zstd-enabled build to a build without it.","commonSituations":"Users build tantivy with default-features=false (e.g. to trim deps or for wasm) but open a pre-existing index whose writer used zstd; mismatched features between the writer and reader of an index; CI builds omitting feature flags used elsewhere.","solutions":["Re-enable the feature: add \"zstd-compression\" to the tantivy/sstable feature list in Cargo.toml and rebuild.","If you do not need zstd, re-index (rebuild the segments) with a compression format your build supports, e.g. SetCompression(Lz4) or none.","Make feature flags consistent across all builds (writer and reader) that touch the same index; pin them in workspace Cargo.toml.","Check cargo tree / Cargo.lock that no default-features=false path is silently dropping the feature."],"exampleFix":"// before\ntantivy = { version = \"0.22\", default-features = false }\n// after\ntantivy = { version = \"0.22\", default-features = false, features = [\"zstd-compression\", \"mmap\"] }","handlingStrategy":"validation","validationCode":"// Check the feature is compiled in before opening an index that may use zstd\n#[cfg(not(feature = \"zstd-compression\"))]\nconst ZSTD_ENABLED: bool = false;\n#[cfg(feature = \"zstd-compression\")]\nconst ZSTD_ENABLED: bool = true;\nfn assert_zstd_available(index_meta: &IndexMetadata) -> Result<(), Error> {\n    if index_meta.compression == Compression::Zstd && !ZSTD_ENABLED {\n        return Err(Error::Internal(\"index uses zstd but zstd-compression feature is disabled\"));\n    }\n    Ok(())\n}","typeGuard":null,"tryCatchPattern":"// Rust io::Error surfaced as Err\nmatch segment_reader.open() {\n    Err(e) if e.kind() == io::ErrorKind::Unsupported\n        && e.to_string().contains(\"zstd-compression\") => {\n        // rebuild with the feature enabled or fall back to re-indexed segments\n    }\n    other => other?,\n}","preventionTips":["Always include zstd-compression in feature lists when sharing/reading externally produced indexes","Keep writer and reader feature flags identical across deployments","Audit default-features = false usages in Cargo.toml","Document required features wherever index files are exchanged"],"tags":["rust","feature-flag","compression","sstable"],"backgroundTag":"missing-cargo-feature","analyzedSha":"b5d8deb80c26924e6b007a5b1a7630f35ca64de4","analyzedAt":"2026-09-05T13:20:51.521Z","contentChangedAt":"2026-09-05T13:20:51.521Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}