{"record":{"id":"b3e1d33e2b416762","repo":"quickwit-oss/tantivy","slug":"file-corrupted-the-file-is-smaller-than-footer-s","errorCode":null,"errorMessage":"File corrupted. The file is smaller than Footer::SIZE_IN_BYTES (len={}).","messagePattern":"File corrupted\\. The file is smaller than Footer::SIZE_IN_BYTES \\(len=(.+?)\\)\\.","errorType":"exception","errorClass":"io::Error","httpStatus":null,"severity":"error","filePath":"src/store/footer.rs","lineNumber":66,"sourceCode":"    const SIZE_IN_BYTES: usize = 28;\n}\n\nimpl DocStoreFooter {\n    pub fn new(\n        offset: u64,\n        decompressor: Decompressor,\n        doc_store_version: DocStoreVersion,\n    ) -> Self {\n        DocStoreFooter {\n            offset,\n            doc_store_version,\n            decompressor,\n        }\n    }\n\n    pub fn extract_footer(file: FileSlice) -> io::Result<(DocStoreFooter, FileSlice)> {\n        if file.len() < DocStoreFooter::SIZE_IN_BYTES {\n            return Err(io::Error::new(\n                io::ErrorKind::UnexpectedEof,\n                format!(\n                    \"File corrupted. The file is smaller than Footer::SIZE_IN_BYTES (len={}).\",\n                    file.len()\n                ),\n            ));\n        }\n        let (body, footer_slice) = file.split_from_end(DocStoreFooter::SIZE_IN_BYTES);\n        let mut footer_bytes = footer_slice.read_bytes()?;\n        let footer = DocStoreFooter::deserialize(&mut footer_bytes)?;\n        Ok((footer, body))\n    }\n}\n\n#[test]\nfn doc_store_footer_test() {\n    // This test is just to safe guard changes on the footer.\n    // When the doc store footer is updated, make sure to update also the serialize/deserialize","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/quickwit-oss/tantivy/blob/b5d8deb80c26924e6b007a5b1a7630f35ca64de4/src/store/footer.rs#L48-L84","documentation":"Thrown by DocStoreFooter::extract_footer when the file slice is shorter than the fixed footer size (DocStoreFooter::SIZE_IN_BYTES). A doc store file must end with a footer; a file too small to contain one cannot be a valid doc store file.","triggerScenarios":"Calling extract_footer() on an empty or nearly empty file; passing the wrong file (not a doc store segment) to the footer parser; reading a file truncated to fewer bytes than the footer requires.","commonSituations":"Pointing tantivy at an empty or wrong path; incomplete download/copy of index directories; files clobbered or truncated by external tooling.","solutions":["Verify the path points to a real, complete doc store/segment file and not an empty or wrong file","Re-copy the index directory fully and compare file sizes against the source","Restore the index from backup or re-index the documents","Check for external processes (cleanup jobs, disk-full events) that may have truncated files"],"exampleFix":"// before\nlet (footer, rest) = DocStoreFooter::extract_footer(file_slice)?;\n// after\nif file_slice.len() < DocStoreFooter::SIZE_IN_BYTES {\n    eprintln!(\"skipping invalid/truncated doc store file of {} bytes\", file_slice.len());\n    return Ok(None);\n}\nlet (footer, rest) = Some(DocStoreFooter::extract_footer(file_slice)?).map(|(f, r)| (f, r))?;","handlingStrategy":"validation","validationCode":"use std::io;\nuse owning_ref::FileSlice; // or your FileSlice type\n\nfn footer_is_readable(file: &FileSlice) -> bool {\n    file.len() >= DocStoreFooter::SIZE_IN_BYTES\n}\n\n// call before extract_footer:\nif !footer_is_readable(&file_slice) {\n    eprintln!(\"file of {} bytes is too small to hold a doc store footer; skipping\", file_slice.len());\n}","typeGuard":"fn is_valid_docstore_file(file: &FileSlice) -> bool {\n    file.len() >= DocStoreFooter::SIZE_IN_BYTES\n}","tryCatchPattern":"match DocStoreFooter::extract_footer(file_slice) {\n    Err(e) if e.kind() == io::ErrorKind::UnexpectedEof => {\n        eprintln!(\"file too small for footer; treating as invalid doc store\");\n        // skip or re-index\n    }\n    other => other.map(|(footer, rest)| footer),\n}","preventionTips":["Check file size > 0 and >= footer size before opening doc store files","Copy index directories completely; compare sizes against source afterwards","Don't point tantivy at empty files or non-index paths","Guard against external cleanup jobs deleting/truncating index files"],"tags":["io","truncation","footer","rust"],"backgroundTag":"truncated-file","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"}