{"record":{"id":"51280f37e7109c28","repo":"vercel/next.js","slug":"fixed-key-block-for-entry-count-entries-is-the-wrong-size","errorCode":null,"errorMessage":"fixed key block for {entry_count} entries is the wrong size","messagePattern":"fixed key block for (.+?) entries is the wrong size","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"turbopack/crates/turbo-persistence/src/static_sorted_file.rs","lineNumber":651,"sourceCode":"        &self,\n        block: &[u8],\n        key_hash: u64,\n        key: &K,\n        layout: KeyBlockLayout,\n        reader: ArcBlockCacheReader<'_>,\n    ) -> Result<SstLookupResult> {\n        ensure!(block.len() >= 6, \"fixed key block too short\");\n        let entry_count = be::read_u24(&block[1..]) as usize;\n        let key_size = be::read_u8(&block[4..]) as usize;\n        let header_type = be::read_u8(&block[5..]);\n        let FixedValueLayout {\n            value_type,\n            val_size,\n            header_size,\n        } = fixed_value_layout(block, header_type)?;\n        let regions = FixedRegions::new(entry_count, layout, key_size, val_size);\n        let entries = &block[header_size..];\n        ensure!(\n            entries.len() == regions.total_len(entry_count),\n            \"fixed key block for {entry_count} entries is the wrong size\"\n        );\n\n        self.lookup_block_inner::<K, FIND_ALL>(entry_count, key_hash, key, layout, reader, |i| {\n            get_fixed_key_entry(entries, i, regions, value_type)\n        })\n    }\n\n    /// Shared binary search + collection logic for both key block variants.\n    ///\n    /// The `get_entry` closure abstracts over the difference between variable-size\n    /// key blocks (offset table lookup) and fixed-size key blocks (stride-based indexing).\n    fn lookup_block_inner<'a, K: QueryKey, const FIND_ALL: bool>(\n        &self,\n        entry_count: usize,\n        key_hash: u64,\n        key: &K,","sourceCodeStart":633,"sourceCodeEnd":669,"githubUrl":"https://github.com/vercel/next.js/blob/34433fd12ee8074ea3f47af9f36255c7390d0301/turbopack/crates/turbo-persistence/src/static_sorted_file.rs#L633-L669","documentation":"For a fixed-layout key block, turbo-persistence computes the exact total byte length the entries region must have (FixedRegions::total_len for entry_count) and requires the block's entries slice to match exactly. A mismatch means the block's declared entry count, key size, and value size do not fit its actual bytes — i.e. the block is corrupt or was written with an incompatible layout.","triggerScenarios":"A fixed-key SST key block where entries.len() != regions.total_len(entry_count) during lookup_variable-style point lookup — truncated block, wrong header_type, or stale cache written by a different version.","commonSituations":"Version skew between cache writer and reader after upgrading Next.js/Turbopack; cache corruption after a crash mid-write.","solutions":["Delete the persistent cache directory and rebuild.","Clear the cache across Next.js/Turbopack version switches to avoid writer/reader layout mismatch.","Confirm the cache directory is not concurrently written by multiple builds.","Reproduce on a fresh cache and report if it persists."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  lookup(key);\n} catch (e) {\n  if (/is the wrong size/.test(String(e))) {\n    resetCache();\n  } else throw e;\n}","preventionTips":["Clear the cache when switching Next.js/Turbopack versions to avoid layout mismatch.","Use dedicated cache directories per project and version.","Verify clean writes: sufficient disk space, no abrupt power loss."],"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"}