{"record":{"id":"4ae4cd953346088d","repo":"quickwit-oss/tantivy","slug":"invalid-doc-store-version-v","errorCode":null,"errorMessage":"Invalid doc store version {v}","messagePattern":"Invalid doc store version (.+?)","errorType":"exception","errorClass":"io::Error","httpStatus":null,"severity":"error","filePath":"src/store/reader.rs","lineNumber":53,"sourceCode":"impl Display for DocStoreVersion {\n    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {\n        match self {\n            DocStoreVersion::V1 => write!(f, \"V1\"),\n            DocStoreVersion::V2 => write!(f, \"V2\"),\n        }\n    }\n}\nimpl BinarySerializable for DocStoreVersion {\n    fn serialize<W: io::Write + ?Sized>(&self, writer: &mut W) -> io::Result<()> {\n        (*self as u32).serialize(writer)\n    }\n\n    fn deserialize<R: io::Read>(reader: &mut R) -> io::Result<Self> {\n        Ok(match u32::deserialize(reader)? {\n            1 => DocStoreVersion::V1,\n            2 => DocStoreVersion::V2,\n            v => {\n                return Err(io::Error::new(\n                    io::ErrorKind::InvalidData,\n                    format!(\"Invalid doc store version {v}\"),\n                ))\n            }\n        })\n    }\n}\n\n/// Reads document off tantivy's [`Store`](./index.html)\npub struct StoreReader {\n    decompressor: Decompressor,\n    doc_store_version: DocStoreVersion,\n    data: FileSlice,\n    skip_index: Arc<SkipIndex>,\n    space_usage: StoreSpaceUsage,\n    cache: BlockCache,\n}\n","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/quickwit-oss/tantivy/blob/b5d8deb80c26924e6b007a5b1a7630f35ca64de4/src/store/reader.rs#L35-L71","documentation":"Thrown during deserialization of DocStoreVersion when the u32 read from the file is neither 1 (V1) nor 2 (V2). The library only understands these doc store format versions; anything else means the file was written by an incompatible tantivy version or the bytes are misaligned/corrupt.","triggerScenarios":"Opening an index written by a newer tantivy that uses a doc store version beyond V2; reading a corrupted or misaligned byte stream as the version field; pointing the reader at a non-doc-store file.","commonSituations":"Upgrading/downgrading tantivy across incompatible format versions; mixing segments written by different library versions in one directory; file corruption shifting the read offset.","solutions":["Read the index with the same (or newer, compatible) tantivy version that wrote it","Rebuild the index with your current tantivy version if a downgrade is required","Verify the segment file is intact and not corrupted/misaligned","Check your index directory does not mix files from different tantivy versions"],"exampleFix":"// before\nlet version = DocStoreVersion::deserialize(&mut reader)?;\n// after\nlet version = match DocStoreVersion::deserialize(&mut reader) {\n    Ok(v) => v,\n    Err(e) if e.kind() == io::ErrorKind::InvalidData => {\n        eprintln!(\"incompatible doc store version, rebuilding index\");\n        return rebuild_index();\n    }\n    Err(e) => return Err(e),\n};","handlingStrategy":"validation","validationCode":"fn read_docstore_version(reader: &mut impl std::io::Read) -> std::io::Result<u32> {\n    let mut buf = [0u8; 4];\n    reader.read_exact(&mut buf)?;\n    let v = u32::from_le_bytes(buf);\n    if v != 1 && v != 2 {\n        return Err(std::io::Error::new(\n            std::io::ErrorKind::InvalidData,\n            format!(\"unsupported doc store version {v}; this tantivy supports 1..=2\"),\n        ));\n    }\n    Ok(v)\n}","typeGuard":"fn is_supported_docstore_version(v: u32) -> bool {\n    matches!(v, 1 | 2)\n}","tryCatchPattern":"match DocStoreVersion::deserialize(&mut reader) {\n    Err(e) if e.kind() == std::io::ErrorKind::InvalidData\n        && e.to_string().starts_with(\"Invalid doc store version\") => {\n        eprintln!(\"index written by incompatible tantivy; re-index required\");\n    }\n    Err(e) => return Err(e.into()),\n    Ok(v) => use_version(v),\n}","preventionTips":["Pin one tantivy version across all processes writing and reading an index","Check the index metadata version before upgrading/downgrading the library","Never mix segment files from different tantivy versions in one directory","Plan migrations: rebuild indexes when the changelog notes a format version bump"],"tags":["io","versioning","serialization","rust"],"backgroundTag":"invalid-version-format","analyzedSha":"b5d8deb80c26924e6b007a5b1a7630f35ca64de4","analyzedAt":"2026-09-05T13:20:51.521Z","contentChangedAt":"2026-09-05T13:20:51.521Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}