{"record":{"id":"1ff71e5ede117182","repo":"vercel/next.js","slug":"key-block-too-short","errorCode":null,"errorMessage":"key block too short","messagePattern":"key block too short","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"turbopack/crates/turbo-persistence/src/static_sorted_file.rs","lineNumber":612,"sourceCode":"            Err(0) => self.index.first_block,\n            Err(i) => be::read_u16(&entries[i - 1][size_of::<u64>()..]),\n        }\n    }\n\n    /// Looks up a key in a key block and the value in a value block.\n    ///\n    /// If `FIND_ALL` is false, returns after finding the first match.\n    /// If `FIND_ALL` is true, collects all entries with the same key.\n    fn lookup_variable_key_block<K: QueryKey, const FIND_ALL: bool>(\n        &self,\n        block: &[u8],\n        key_hash: u64,\n        key: &K,\n        layout: KeyBlockLayout,\n        reader: ArcBlockCacheReader<'_>,\n    ) -> Result<SstLookupResult> {\n        let hash_len = layout.hash_len();\n        ensure!(block.len() >= 4, \"key block too short\");\n        let entry_count = be::read_u24(&block[1..]) as usize;\n        let data = &block[4..];\n        let table_len = entry_count * key_block_table_stride(hash_len);\n        ensure!(\n            data.len() >= table_len,\n            \"key block too short for {entry_count} entries\"\n        );\n        let offsets = &data[..table_len];\n        let entries = &data[table_len..];\n\n        self.lookup_block_inner::<K, FIND_ALL>(entry_count, key_hash, key, layout, reader, |i| {\n            get_key_entry(offsets, entries, entry_count, i, hash_len)\n        })\n    }\n\n    /// Looks up a key in a fixed-size key block.\n    ///\n    /// Fixed-size key blocks store entries at predictable offsets (no offset table),","sourceCodeStart":594,"sourceCodeEnd":630,"githubUrl":"https://github.com/vercel/next.js/blob/34433fd12ee8074ea3f47af9f36255c7390d0301/turbopack/crates/turbo-persistence/src/static_sorted_file.rs#L594-L630","documentation":"In lookup_variable_key_block, a key block must contain at least a 4-byte header before its entry offset table can be read. This ensure! fires when the block fetched from the block cache is shorter than 4 bytes, indicating a corrupt or truncated key block.","triggerScenarios":"A variable-key SST key block read via ArcBlockCacheReader that is shorter than 4 bytes — corrupt block data in the file or block cache.","commonSituations":"Bit-rot or truncation in a Turbopack persistent cache file; a block-cache entry pointing at the wrong byte range after a torn write.","solutions":["Delete the persistent cache directory and rebuild it.","Check filesystem integrity (fsck / SMART) if corruption recurs.","Ensure the cache is not on a network/shared volume subject to partial writes.","If reproducible, report the SST file to the Turbopack team as a corruption case."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  lookup(key);\n} catch (e) {\n  if (/key block too short/.test(String(e))) {\n    resetCache(); // delete cache dir and reopen\n  } else throw e;\n}","preventionTips":["Delete and regenerate the cache on any corruption error instead of retrying against the same files.","Check storage health if SST corruption recurs.","Avoid network/shared filesystems for the cache directory."],"tags":["storage","corruption","cache","rust"],"backgroundTag":"internal-invariant-violation","analyzedSha":"34433fd12ee8074ea3f47af9f36255c7390d0301","analyzedAt":"2026-09-20T18:20:20.576Z","contentChangedAt":"2026-09-20T18:20:20.576Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}