xai-org/grok-build · error · io::Error
compressed index requires 'compression' feature
Error message
compressed index requires 'compression' feature
What it means
The index file can be stored zstd-compressed, but decompression requires the optional 'compression' cargo feature. When the binary was built without that feature and read_from encounters a compressed index, it cannot decode it and returns io::ErrorKind::InvalidData, "compressed index requires 'compression' feature".
Source
Thrown at crates/codegen/xai-grok-workspace/src/file_system/index.rs:935
r.read_exact(&mut buf2)?;
let flags = u16::from_le_bytes(buf2);
// Handle compression
if flags & FLAG_COMPRESSED != 0 {
#[cfg(feature = "compression")]
{
r.read_exact(&mut buf4)?;
let _n_segs = u32::from_le_bytes(buf4);
r.read_exact(&mut buf4)?;
let _n_entries = u32::from_le_bytes(buf4);
let mut compressed = Vec::new();
r.read_to_end(&mut compressed)?;
let decompressed = zstd::stream::decode_all(io::Cursor::new(compressed))?;
return Self::from_bytes(&decompressed);
}
#[cfg(not(feature = "compression"))]
return Err(io::Error::new(
io::ErrorKind::InvalidData,
"compressed index requires 'compression' feature",
));
}
r.read_exact(&mut buf4)?;
let n_segs = u32::from_le_bytes(buf4) as usize;
r.read_exact(&mut buf4)?;
let n_entries = u32::from_le_bytes(buf4) as usize;
// Read segment table (supports non-UTF-8 bytes)
let mut interner = StringInterner::with_capacity(n_segs * 20, n_segs);
let mut seg_id_map = Vec::with_capacity(n_segs);
for _ in 0..n_segs {
r.read_exact(&mut buf2)?;
let len = u16::from_le_bytes(buf2) as usize;
let mut seg_buf = vec![0u8; len];
r.read_exact(&mut seg_buf)?;View on GitHub (pinned to bc7f02eddd)
Solutions
- Enable the feature: add xai-grok-workspace = { version = "...", features = ["compression"] } in Cargo.toml and rebuild.
- Regenerate the index uncompressed by rewriting it with a build that has compression disabled (write path will skip compression).
- Align feature flags across your workspace so every consumer enables the same 'compression' setting.
- Run `cargo tree -f "{p} {f}"` to confirm which build actually has the feature and fix feature unification.
Example fix
// before
xai-grok-workspace = "0.4"
// after
xai-grok-workspace = { version = "0.4", features = ["compression"] } Defensive patterns
Strategy: fallback
Validate before calling
fn compressed_index_supported() -> bool {
cfg!(feature = "compression")
}
// inspect header/flag or just ensure the feature is on before reading Try / catch
match Index::read_from(&mut file) {
Ok(i) => i,
Err(e) if e.to_string().contains("requires 'compression' feature") => {
// rebuild an uncompressed index instead of failing
Index::rebuild(&workspace_root)?
}
Err(e) => return Err(e.into()),
} Prevention
- Always enable features = ["compression"] when the index may be compressed
- Keep feature flags consistent across all workspace crates (check cargo tree)
- Standardize the index storage format (compressed or not) in your deployment
When it happens
Trigger: Reading an index file that was written in compressed form while the crate was compiled without the 'compression' feature (e.g. default build, or a dependency pinned the feature off).
Common situations: Index was produced by a build with the compression feature enabled, then consumed by a build without it; a dependency resolver (feature unification) disabled the feature; switching from a full build to a minimal build in CI.
Related errors
- failed to build request: {e}
- failed to serialize MCP server {name}: {e}
- failed to serialize MCP server config: {e}
- failed to parse {}: {e}
- -32603
AI-assisted analysis of xai-org/grok-build@bc7f02eddd (2026-08-31).
Data as JSON: /api/errors/7e05abd53bf4bfaf.
Report an issue: GitHub.