xai-org/grok-build · error · io::Error
unsupported version: {}
Error message
unsupported version: {} What it means
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>'.
Source
Thrown at crates/codegen/xai-grok-workspace/src/file_system/index.rs:911
Self::read_from(&mut io::Cursor::new(data))
}
/// Read from a reader in binary format.
pub fn read_from<R: Read>(r: &mut R) -> io::Result<Self> {
// Header
let mut magic = [0u8; 4];
r.read_exact(&mut magic)?;
if &magic != MAGIC_INDEX {
return Err(io::Error::new(io::ErrorKind::InvalidData, "invalid magic"));
}
let mut buf2 = [0u8; 2];
let mut buf4 = [0u8; 4];
r.read_exact(&mut buf2)?;
let version = u16::from_le_bytes(buf2);
if version != VERSION {
return Err(io::Error::new(
io::ErrorKind::InvalidData,
format!("unsupported version: {}", version),
));
}
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();View on GitHub (pinned to bc7f02eddd)
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.
Example fix
// before
let idx = Index::read_from(&mut file)?;
// after
let idx = match Index::read_from(&mut file) {
Ok(i) => i,
Err(e) if e.to_string().starts_with("unsupported version") => {
std::fs::remove_file(&index_path)?; // stale format
Index::rebuild(&workspace_root)?
}
Err(e) => return Err(e.into()),
}; Defensive patterns
Strategy: try-catch
Validate before calling
fn read_version(path: &std::path::Path) -> std::io::Result<Option<u16>> {
use std::io::Read;
let mut f = std::fs::File::open(path)?;
f.seek(std::io::SeekFrom::Start(4))?;
let mut b = [0u8; 2];
if f.read_exact(&mut b).is_err() { return Ok(None); }
Ok(Some(u16::from_le_bytes(b)))
}
// if Some(v) and v != VERSION -> regenerate before loading Try / catch
match Index::read_from(&mut file) {
Ok(i) => i,
Err(e) if e.to_string().starts_with("unsupported version") => {
std::fs::remove_file(&index_path)?;
Index::rebuild(&workspace_root)?
}
Err(e) => return Err(e.into()),
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Unsupported checkpoint schema version {schema_version}. Cann
- invalid magic
- invalid segment id
- Leader does not advertise capabilities (legacy version)
- No `version` field in plugin.json. Set a version to use `gro
AI-assisted analysis of xai-org/grok-build@bc7f02eddd (2026-08-31).
Data as JSON: /api/errors/773ca2bab16f0f65.
Report an issue: GitHub.