{"record":{"id":"addaae65290f9447","repo":"vercel/next.js","slug":"mixed-type-fixed-key-block-too-short","errorCode":null,"errorMessage":"mixed-type fixed key block too short","messagePattern":"mixed-type fixed key block too short","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"turbopack/crates/turbo-persistence/src/static_sorted_file.rs","lineNumber":1705,"sourceCode":"///\n/// All entries have the same key size and value type, so positions are computed\n/// arithmetically with no offset table indirection.\n/// How a fixed-size key block encodes its entry values, decoded from the block header.\nstruct FixedValueLayout {\n    /// The type shared by every entry, or `None` if each entry carries its own type byte.\n    value_type: Option<u8>,\n    /// Value bytes per entry, including any per-entry type byte.\n    val_size: usize,\n    /// Total header size, which the entry data follows.\n    header_size: usize,\n}\n\n/// Decodes the value layout from a fixed-size key block header.\nfn fixed_value_layout(block: &[u8], header_type: u8) -> Result<FixedValueLayout> {\n    if header_type == FIXED_KEY_BLOCK_MIXED_VALUE_TYPE {\n        // Mixed-type block: the value size follows the header's type byte, and each entry\n        // carries its own type.\n        ensure!(block.len() >= 7, \"mixed-type fixed key block too short\");\n        // Validate the value footprint byte\n        let value_footprint = be::read_u8(&block[6..]) as usize;\n        ensure!(\n            value_footprint <= MAX_INLINE_VALUE_SIZE,\n            \"mixed-type fixed key block claims a {value_footprint} byte value footprint, over the \\\n             {MAX_INLINE_VALUE_SIZE} byte maximum\"\n        );\n        Ok(FixedValueLayout {\n            value_type: None,\n            // +1 for the per-entry type byte, which is part of the stride.\n            val_size: value_footprint + 1,\n            header_size: 7,\n        })\n    } else {\n        Ok(FixedValueLayout {\n            value_type: Some(header_type),\n            val_size: entry_val_size(header_type)?,\n            header_size: 6,","sourceCodeStart":1687,"sourceCodeEnd":1723,"githubUrl":"https://github.com/vercel/next.js/blob/34433fd12ee8074ea3f47af9f36255c7390d0301/turbopack/crates/turbo-persistence/src/static_sorted_file.rs#L1687-L1723","documentation":"When a fixed-size key block uses the mixed value type, fixed_value_layout expects at least 7 bytes so it can read the value footprint byte at offset 6. This error means the block buffer is shorter than the minimum header size required by the mixed-type layout, i.e. the block is truncated or corrupt.","triggerScenarios":"Calling fixed_value_layout (during block decode) with header_type == FIXED_KEY_BLOCK_MIXED_VALUE_TYPE and block.len() < 7; caused by truncated or malformed persisted data in a static sorted file.","commonSituations":"Incomplete cache writes after a crash or kill, corrupted cache files, or a reader opened against data written by an incompatible format version.","solutions":["Delete the affected cache/store directory and rebuild the cache.","Check for crashes or forced kills during write; ensure writes complete and the process is not terminated mid-flush.","If reproducible, verify reader/writer version compatibility and file an upstream bug with the reproduction steps."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"// Validate persisted file integrity before decode\nfunction blockIsReadable(block: Buffer): boolean {\n  return block.length >= 7 // minimum mixed-type fixed key block header\n}","typeGuard":null,"tryCatchPattern":"try {\n  const layout = fixedValueLayout(block, headerType)\n} catch (e) {\n  if (String(e).includes('too short')) {\n    // fall back to rebuilding the store from source data\n  } else throw e\n}","preventionTips":["Ensure writes are atomic or checksummed so truncated blocks are detected early.","Don't share cache directories across machines with different format versions.","Rebuild caches after abrupt shutdowns or OOM kills."],"tags":["data-corruption","cache","persistence","truncated-data"],"backgroundTag":"schema-validation-failed","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"}