{"record":{"id":"dbd7a5dc8ccc8e51","repo":"qdrant/qdrant","slug":"invaliddata-dbd7a5","errorCode":"InvalidData","errorMessage":"Invalid header","messagePattern":"Invalid header","errorType":"exception","errorClass":"io::Error","httpStatus":null,"severity":"error","filePath":"lib/common/common/src/persisted_hashmap/uio/mod.rs","lineNumber":75,"sourceCode":"        options.populate = options.populate.or_partial(0..HEADER_AND_BASIC_PHF_SIZE);\n\n        fs.schedule_prefetch(path.as_ref(), Some(options), None)\n    }\n\n    /// Load the hash map from file.\n    pub fn open<Fs: UniversalReadFs<File = S>>(\n        fs: &Fs,\n        path: impl AsRef<Path>,\n        options: OpenOptions,\n        extra: Fs::OpenExtra,\n    ) -> UioResult<Self> {\n        let storage = TypedStorage::<S, u8>::open(fs, path, options, extra)?;\n\n        // 1. Read header.\n        let header_bytes =\n            storage.read(ReadRange::new(0, size_of::<Header>() as u64), Sequential)?;\n        let (header, _) = Header::read_from_prefix(&header_bytes)\n            .map_err(|_| io::Error::new(io::ErrorKind::InvalidData, \"Invalid header\"))?;\n\n        if header.key_type != K::NAME {\n            return Err(UniversalIoError::from(io::Error::new(\n                io::ErrorKind::InvalidData,\n                \"Key type mismatch\",\n            )));\n        }\n\n        // 2. Read PHF. The region between the header and buckets_pos contains the\n        //    serialised PHF followed by padding; `Function::read` consumes only what\n        //    it needs and ignores trailing bytes.\n        let phf_region_start = size_of::<Header>() as u64;\n        let phf_region_len = header\n            .buckets_pos\n            .checked_sub(phf_region_start)\n            .ok_or_else(|| {\n                io::Error::new(io::ErrorKind::InvalidData, \"buckets_pos before header end\")\n            })?;","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/qdrant/qdrant/blob/74f3e85b9473c62560006c043e13737ce6b48412/lib/common/common/src/persisted_hashmap/uio/mod.rs#L57-L93","documentation":"UniversalHashMap::open (the universal-io variant of the persisted hash map) failed to parse the fixed-size Header from the first bytes of the file. Header::read_from_prefix returns an error when there are fewer bytes than size_of::<Header>() or the bytes cannot form a valid Header — in practice an empty, truncated, or non-hashmap file.","triggerScenarios":"UniversalHashMap::open on an empty (0-byte) file, a file smaller than the header, a placeholder file created ahead of the real data, or a completely wrong file at the expected path.","commonSituations":"A download/replication step failed silently and left an empty file; a pre-created placeholder was never replaced; pointing the open call at the wrong path (e.g., a bitmask or tar file instead of the map).","solutions":["Check the file length is at least the header size and clearly non-zero before opening","Re-download or regenerate the hash map file","Verify the path points at a file actually produced by the persisted-hashmap writer"],"exampleFix":"// before\nlet map = UniversalHashMap::open(&fs, &path, options, extra)?;\n\n// after: guard against empty/partial files\nlet len = std::fs::metadata(&path)?.len();\nif len < MIN_EXPECTED_MAP_SIZE {\n    return Err(format!(\"map file too small: {len} bytes\").into());\n}\nlet map = UniversalHashMap::open(&fs, &path, options, extra)?;","handlingStrategy":"validation","validationCode":"let len = fs.len(&path)?; // or std::fs::metadata(&path)?.len()\nif len < HEADER_AND_BASIC_PHF_SIZE {\n    return Err(UniversalIoError::Io(io::Error::new(\n        io::ErrorKind::InvalidData,\n        format!(\"map file too small ({len} bytes); refusing to open\"),\n    )));\n}","typeGuard":null,"tryCatchPattern":"match UniversalHashMap::open(&fs, &path, options, extra) {\n    Err(UniversalIoError::Io(ref e)) if e.kind() == io::ErrorKind::InvalidData && e.to_string().contains(\"Invalid header\") => {\n        re_fetch_or_regenerate(&path)? // empty/truncated/wrong file\n    }\n    other => other?,\n}","preventionTips":["Never pre-create placeholder files at the final path; write to a temp name and rename on completion","Validate downloads (status code, content-length, checksum) before promoting files to the map path","Log the file length on open failure to distinguish empty vs wrong-type files"],"tags":["rust","hashmap","invalid-data","truncated-file"],"backgroundTag":null,"analyzedSha":"74f3e85b9473c62560006c043e13737ce6b48412","analyzedAt":"2026-08-22T20:16:20.450Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}