{"record":{"id":"fa01c41c91886de2","repo":"astrid-runtime/astrid","slug":"invalid-interior-astrid-volume-record-length-at-o","errorCode":null,"errorMessage":"invalid interior Astrid volume record length at {offset}","messagePattern":"invalid interior Astrid volume record length at (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/astrid-storage/src/volume/hosted/recover.rs","lineNumber":415,"sourceCode":"        logical_offset: u64::from_le_bytes(read_array::<8>(&fixed[27..35])?),\n        checksum: read_array::<32>(&fixed[43..75])?,\n        name,\n        payload_offset,\n        payload_len,\n    }))\n}\n\nfn handle_bad_length(\n    file: &File,\n    offset: u64,\n    physical_len: u64,\n    total_len: u64,\n    remaining: u64,\n) -> io::Result<Option<RecordHeader>> {\n    if total_len > remaining\n        && has_physically_valid_record_after(file, offset.saturating_add(1), physical_len)?\n    {\n        return Err(io::Error::new(\n            io::ErrorKind::InvalidData,\n            format!(\"invalid interior Astrid volume record length at {offset}\"),\n        ));\n    }\n    if total_len > remaining {\n        return Ok(None);\n    }\n    Err(io::Error::new(\n        io::ErrorKind::InvalidData,\n        format!(\"invalid Astrid volume record length at {offset}\"),\n    ))\n}\n\nfn read_record_payload(file: &File, header: &RecordHeader) -> io::Result<Option<Vec<u8>>> {\n    if header.operation == Operation::Write {\n        return Ok(None);\n    }\n    let max_payload = if header.operation == Operation::Commit {","sourceCodeStart":397,"sourceCodeEnd":433,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-storage/src/volume/hosted/recover.rs#L397-L433","documentation":"When a record's total_len exceeds the remaining bytes in the region, the recovery code checks whether another physically valid record starts right after this one. If such a valid record exists, the oversized length is treated as genuine corruption of an interior record (not just a torn tail), and recovery aborts with InvalidData instead of treating it as a truncation boundary.","triggerScenarios":"handle_bad_length (invoked from read_header) sees total_len > remaining AND has_physically_valid_record_after(offset+1) returns true, meaning a plausible record follows a record claiming an impossible length — physical corruption inside the volume, not simple end-of-file truncation.","commonSituations":"Disk-sector corruption or bit rot flipping bytes in a length field mid-file; a buggy writer previously appended garbage that resembles a valid record header; recovery run on a partially damaged volume after a hardware fault.","solutions":["Restore the volume from the most recent backup or snapshot; the interior record is corrupted and cannot be trusted.","Re-run recovery from the last known-good commit/footer to rebuild from an earlier consistent point.","Inspect the file around the reported offset to confirm hardware corruption; run filesystem/disk checks.","If the corrupted record's data is recoverable from another source, re-write it and re-run recovery."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"match recover_from_headers(&file) {\n    Err(e) if e.to_string().contains(\"invalid interior Astrid volume record length\") => {\n        // fall back to last committed footer/backup; flag volume for inspection\n    }\n    other => other?,\n}","preventionTips":["Take regular volume snapshots so you can fall back to a consistent point.","Run volumes on storage with checksumming (or fs-level integrity) where possible.","Never manually edit or patch volume files.","Recover from the last committed footer rather than raw headers when corruption is suspected."],"tags":["storage","data-corruption","io","recovery"],"backgroundTag":"checksum-mismatch","analyzedSha":"affd8760f44190dbdfbec23403f4c4b642c33112","analyzedAt":"2026-09-09T21:28:12.402Z","contentChangedAt":"2026-09-09T21:28:12.402Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}