{"record":{"id":"eef6c7f531775d11","repo":"quickwit-oss/tantivy","slug":"invaliddata-eef6c7","errorCode":"InvalidData","errorMessage":"Footer magic byte mismatch. File corrupted or index was created using old an tantivy version which is not supported anymore. Please use tantivy 0.15 or above to recreate the index.","messagePattern":"Footer magic byte mismatch\\. File corrupted or index was created using old an tantivy version which is not supported anymore\\. Please use tantivy 0\\.15 or above to recreate the index\\.","errorType":"error_code","errorClass":"io::Error","httpStatus":null,"severity":"error","filePath":"src/directory/footer.rs","lineNumber":73,"sourceCode":"        if file.len() < 4 {\n            return Err(io::Error::new(\n                io::ErrorKind::UnexpectedEof,\n                format!(\n                    \"File corrupted. The file is smaller than 4 bytes (len={}).\",\n                    file.len()\n                ),\n            ));\n        }\n\n        let footer_metadata_len = <(u32, u32)>::SIZE_IN_BYTES;\n        let (footer_len, footer_magic_byte): (u32, u32) = file\n            .slice_from_end(footer_metadata_len)\n            .read_bytes()?\n            .as_ref()\n            .deserialize()?;\n\n        if footer_magic_byte != FOOTER_MAGIC_NUMBER {\n            return Err(io::Error::new(\n                io::ErrorKind::InvalidData,\n                \"Footer magic byte mismatch. File corrupted or index was created using old an \\\n                 tantivy version which is not supported anymore. Please use tantivy 0.15 or above \\\n                 to recreate the index.\",\n            ));\n        }\n\n        if footer_len > FOOTER_MAX_LEN {\n            return Err(io::Error::new(\n                io::ErrorKind::InvalidData,\n                format!(\n                    \"Footer seems invalid as it suggests a footer len of {footer_len}. File is \\\n                     corrupted, or the index was created with a different & old version of \\\n                     tantivy.\"\n                ),\n            ));\n        }\n        let total_footer_size = footer_len as usize + footer_metadata_len;","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/quickwit-oss/tantivy/blob/b5d8deb80c26924e6b007a5b1a7630f35ca64de4/src/directory/footer.rs#L55-L91","documentation":"After reading the footer's magic number, extract_footer compares it against FOOTER_MAGIC_NUMBER. A mismatch means the file was not written by a tantivy version that uses the current footer format (>= 0.15), or the file is simply not a tantivy index file.","triggerScenarios":"Opening an index created with tantivy < 0.15; calling extract_footer on a non-tantivy file that happens to be in the index directory; byte-level corruption of the last bytes of a segment file.","commonSituations":"Upgrading tantivy across a major version and pointing the new version at an old index directory; mixing segment files from different tantivy versions; accidentally passing a log or temp file to extract_footer.","solutions":["Recreate the index with tantivy 0.15 or above (the error message's own remedy); old footer formats are not supported","Restore an index that matches the tantivy version in use, or pin your tantivy version to one compatible with the existing index","Verify the file is actually a tantivy segment (check the magic bytes with a hex dump)","Re-index from the original documents if no compatible version/backup exists"],"exampleFix":"// before (Cargo.toml): opening a pre-0.15 index with a newer tantivy\ntantivy = \"0.21\"\n// after: reindex old data with 0.15+ first, or keep a matching version during migration\ntantivy = \"0.15\" // migrate, then upgrade and re-save with the new version","handlingStrategy":"validation","validationCode":"// check magic bytes before opening with an upgraded tantivy\nlet tail = /* read last 4 bytes of the file */;\nlet magic = u32::from_le_bytes(tail.try_into().unwrap());\nif magic != 0x1af0e11c { /* wrong format: reindex or downgrade */ }","typeGuard":null,"tryCatchPattern":"match extract_footer(file_slice) {\n    Err(e) if e.kind() == io::ErrorKind::InvalidData\n        && e.to_string().contains(\"magic byte mismatch\") => {\n        eprintln!(\"incompatible index version; reindex with tantivy 0.15+\");\n    }\n    Err(e) => return Err(e),\n    Ok(v) => v,\n}","preventionTips":["Record the tantivy version that created an index and pin readers to compatible versions","Re-index (migrate) after major tantivy upgrades instead of reusing old directories","Never mix segment files from different tantivy versions in one directory","Keep the original documents available for re-indexing"],"tags":["io","footer","version-mismatch","corrupt-file"],"backgroundTag":"footer-magic-mismatch","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"}