{"record":{"id":"7e05abd53bf4bfaf","repo":"xai-org/grok-build","slug":"compressed-index-requires-compression-feature","errorCode":null,"errorMessage":"compressed index requires 'compression' feature","messagePattern":"compressed index requires 'compression' feature","errorType":"exception","errorClass":"io::Error","httpStatus":null,"severity":"error","filePath":"crates/codegen/xai-grok-workspace/src/file_system/index.rs","lineNumber":935,"sourceCode":"        r.read_exact(&mut buf2)?;\n        let flags = u16::from_le_bytes(buf2);\n\n        // Handle compression\n        if flags & FLAG_COMPRESSED != 0 {\n            #[cfg(feature = \"compression\")]\n            {\n                r.read_exact(&mut buf4)?;\n                let _n_segs = u32::from_le_bytes(buf4);\n                r.read_exact(&mut buf4)?;\n                let _n_entries = u32::from_le_bytes(buf4);\n\n                let mut compressed = Vec::new();\n                r.read_to_end(&mut compressed)?;\n                let decompressed = zstd::stream::decode_all(io::Cursor::new(compressed))?;\n                return Self::from_bytes(&decompressed);\n            }\n            #[cfg(not(feature = \"compression\"))]\n            return Err(io::Error::new(\n                io::ErrorKind::InvalidData,\n                \"compressed index requires 'compression' feature\",\n            ));\n        }\n\n        r.read_exact(&mut buf4)?;\n        let n_segs = u32::from_le_bytes(buf4) as usize;\n        r.read_exact(&mut buf4)?;\n        let n_entries = u32::from_le_bytes(buf4) as usize;\n\n        // Read segment table (supports non-UTF-8 bytes)\n        let mut interner = StringInterner::with_capacity(n_segs * 20, n_segs);\n        let mut seg_id_map = Vec::with_capacity(n_segs);\n        for _ in 0..n_segs {\n            r.read_exact(&mut buf2)?;\n            let len = u16::from_le_bytes(buf2) as usize;\n            let mut seg_buf = vec![0u8; len];\n            r.read_exact(&mut seg_buf)?;","sourceCodeStart":917,"sourceCodeEnd":953,"githubUrl":"https://github.com/xai-org/grok-build/blob/bc7f02eddd3d84085849dc19ed216f11c23b0571/crates/codegen/xai-grok-workspace/src/file_system/index.rs#L917-L953","documentation":"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\".","triggerScenarios":"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).","commonSituations":"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.","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."],"exampleFix":"// before\nxai-grok-workspace = \"0.4\"\n// after\nxai-grok-workspace = { version = \"0.4\", features = [\"compression\"] }","handlingStrategy":"fallback","validationCode":"fn compressed_index_supported() -> bool {\n    cfg!(feature = \"compression\")\n}\n// inspect header/flag or just ensure the feature is on before reading","typeGuard":null,"tryCatchPattern":"match Index::read_from(&mut file) {\n    Ok(i) => i,\n    Err(e) if e.to_string().contains(\"requires 'compression' feature\") => {\n        // rebuild an uncompressed index instead of failing\n        Index::rebuild(&workspace_root)?\n    }\n    Err(e) => return Err(e.into()),\n}","preventionTips":["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"],"tags":["serialization","feature-flags","compression","cargo"],"backgroundTag":"missing-feature-flag","analyzedSha":"bc7f02eddd3d84085849dc19ed216f11c23b0571","analyzedAt":"2026-08-31T04:59:42.031Z","schemaVersion":2},"datasetVersion":"2026-08-31T09:17:48.483Z"}