quickwit-oss/tantivy · error · io::Error

zstd-compression feature is not enabled

Error message

zstd-compression feature is not enabled

What it means

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.

Source

Thrown at sstable/src/block_reader.rs:120

                return Err(io::Error::new(
                    io::ErrorKind::UnexpectedEof,
                    "failed to read block content",
                ));
            }
            if compress == 1 {
                #[cfg(feature = "zstd-compression")]
                {
                    let required_capacity =
                        Decompressor::upper_bound(&self.reader[..block_len]).unwrap_or(1024 * 1024);
                    self.buffer.reserve(required_capacity);
                    Decompressor::new()?
                        .decompress_to_buffer(&self.reader[..block_len], &mut self.buffer)?;

                    self.reader.advance(block_len);
                }

                if cfg!(not(feature = "zstd-compression")) {
                    return Err(io::Error::new(
                        io::ErrorKind::Unsupported,
                        "zstd-compression feature is not enabled",
                    ));
                }
            } else {
                self.buffer.resize(block_len, 0u8);
                self.reader.read_exact(&mut self.buffer[..])?;
            }

            return Ok(true);
        }
    }

    #[inline(always)]
    pub fn offset(&self) -> usize {
        self.offset
    }

View on GitHub (pinned to b5d8deb80c)

Solutions

  1. Re-enable the feature: add "zstd-compression" to the tantivy/sstable feature list in Cargo.toml and rebuild.
  2. If you do not need zstd, re-index (rebuild the segments) with a compression format your build supports, e.g. SetCompression(Lz4) or none.
  3. Make feature flags consistent across all builds (writer and reader) that touch the same index; pin them in workspace Cargo.toml.
  4. Check cargo tree / Cargo.lock that no default-features=false path is silently dropping the feature.

Example fix

// before
tantivy = { version = "0.22", default-features = false }
// after
tantivy = { version = "0.22", default-features = false, features = ["zstd-compression", "mmap"] }
Defensive patterns

Strategy: validation

Validate before calling

// Check the feature is compiled in before opening an index that may use zstd
#[cfg(not(feature = "zstd-compression"))]
const ZSTD_ENABLED: bool = false;
#[cfg(feature = "zstd-compression")]
const ZSTD_ENABLED: bool = true;
fn assert_zstd_available(index_meta: &IndexMetadata) -> Result<(), Error> {
    if index_meta.compression == Compression::Zstd && !ZSTD_ENABLED {
        return Err(Error::Internal("index uses zstd but zstd-compression feature is disabled"));
    }
    Ok(())
}

Try / catch

// Rust io::Error surfaced as Err
match segment_reader.open() {
    Err(e) if e.kind() == io::ErrorKind::Unsupported
        && e.to_string().contains("zstd-compression") => {
        // rebuild with the feature enabled or fall back to re-indexed segments
    }
    other => other?,
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of quickwit-oss/tantivy@b5d8deb80c (2026-09-05). Data as JSON: /api/errors/92e9ea41366acfbe. Report an issue: GitHub.