{"record":{"id":"773ca2bab16f0f65","repo":"xai-org/grok-build","slug":"unsupported-version","errorCode":null,"errorMessage":"unsupported version: {}","messagePattern":"unsupported version: (.+?)","errorType":"exception","errorClass":"io::Error","httpStatus":null,"severity":"error","filePath":"crates/codegen/xai-grok-workspace/src/file_system/index.rs","lineNumber":911,"sourceCode":"        Self::read_from(&mut io::Cursor::new(data))\n    }\n\n    /// Read from a reader in binary format.\n    pub fn read_from<R: Read>(r: &mut R) -> io::Result<Self> {\n        // Header\n        let mut magic = [0u8; 4];\n        r.read_exact(&mut magic)?;\n        if &magic != MAGIC_INDEX {\n            return Err(io::Error::new(io::ErrorKind::InvalidData, \"invalid magic\"));\n        }\n\n        let mut buf2 = [0u8; 2];\n        let mut buf4 = [0u8; 4];\n\n        r.read_exact(&mut buf2)?;\n        let version = u16::from_le_bytes(buf2);\n        if version != VERSION {\n            return Err(io::Error::new(\n                io::ErrorKind::InvalidData,\n                format!(\"unsupported version: {}\", version),\n            ));\n        }\n\n        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();","sourceCodeStart":893,"sourceCodeEnd":929,"githubUrl":"https://github.com/xai-org/grok-build/blob/bc7f02eddd3d84085849dc19ed216f11c23b0571/crates/codegen/xai-grok-workspace/src/file_system/index.rs#L893-L929","documentation":"After the magic header, read_from reads a little-endian u16 version field and requires it to equal the VERSION constant the library currently writes. Any other version means the on-disk format is incompatible and it fails with io::ErrorKind::InvalidData, 'unsupported version: <n>'.","triggerScenarios":"Calling Index::read_from on an index file whose version field differs from VERSION — i.e. the file was written by an older or newer release of the library with a different binary layout.","commonSituations":"Upgrading or downgrading the library/workspace version while keeping the old index file on disk; copying an index between deployments built from different code versions.","solutions":["Regenerate the index with the current library version (delete the stale file and rebuild).","Use a library version matching the file's version to read the old index, then re-save it.","Check the version bytes in the file and migrate the data if a migration path exists."],"exampleFix":"// before\nlet idx = Index::read_from(&mut file)?;\n// after\nlet idx = match Index::read_from(&mut file) {\n    Ok(i) => i,\n    Err(e) if e.to_string().starts_with(\"unsupported version\") => {\n        std::fs::remove_file(&index_path)?; // stale format\n        Index::rebuild(&workspace_root)?\n    }\n    Err(e) => return Err(e.into()),\n};","handlingStrategy":"try-catch","validationCode":"fn read_version(path: &std::path::Path) -> std::io::Result<Option<u16>> {\n    use std::io::Read;\n    let mut f = std::fs::File::open(path)?;\n    f.seek(std::io::SeekFrom::Start(4))?;\n    let mut b = [0u8; 2];\n    if f.read_exact(&mut b).is_err() { return Ok(None); }\n    Ok(Some(u16::from_le_bytes(b)))\n}\n// if Some(v) and v != VERSION -> regenerate before loading","typeGuard":null,"tryCatchPattern":"match Index::read_from(&mut file) {\n    Ok(i) => i,\n    Err(e) if e.to_string().starts_with(\"unsupported version\") => {\n        std::fs::remove_file(&index_path)?;\n        Index::rebuild(&workspace_root)?\n    }\n    Err(e) => return Err(e.into()),\n}","preventionTips":["Delete stale index files when upgrading the library version","Never share index files between deployments of different builds","Log the on-disk version at startup to detect format drift early"],"tags":["serialization","versioning","binary-format","compatibility"],"backgroundTag":"unsupported-format-version","analyzedSha":"bc7f02eddd3d84085849dc19ed216f11c23b0571","analyzedAt":"2026-08-31T04:59:42.031Z","schemaVersion":2},"datasetVersion":"2026-08-31T09:17:48.483Z"}