{"record":{"id":"671f36c57dfd34ce","repo":"astrid-runtime/astrid","slug":"invalid-astrid-volume-record-magic-at-offset","errorCode":null,"errorMessage":"invalid Astrid volume record magic at {offset}","messagePattern":"invalid Astrid volume record magic at (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/astrid-storage/src/volume/hosted/recover.rs","lineNumber":360,"sourceCode":"                .ok_or_else(|| invalid_transition(\"missing metadata transaction payload\"))?;\n            let mutations = decode_metadata_mutations(payload)?;\n            apply_metadata_mutations(regions, &mutations)?;\n        },\n    }\n    Ok(())\n}\n\nfn read_header(file: &File, offset: u64, physical_len: u64) -> io::Result<Option<RecordHeader>> {\n    let remaining = physical_len.saturating_sub(offset);\n    if remaining < RECORD_FIXED_BYTES as u64 {\n        return Ok(None);\n    }\n    #[cfg(test)]\n    READ_HEADER_COUNT.with(|count| count.set(count.get().saturating_add(1)));\n    let mut fixed = [0_u8; RECORD_FIXED_BYTES];\n    read_exact_at(file, offset, &mut fixed)?;\n    if fixed[..RECORD_MAGIC.len()] != RECORD_MAGIC {\n        return Err(io::Error::new(\n            io::ErrorKind::InvalidData,\n            format!(\"invalid Astrid volume record magic at {offset}\"),\n        ));\n    }\n    let total_len = u64::from_le_bytes(read_array::<8>(&fixed[8..16])?);\n    let name_length = usize::from(u16::from_le_bytes(read_array::<2>(&fixed[25..27])?));\n    let payload_len = u64::from_le_bytes(read_array::<8>(&fixed[35..43])?);\n    let declared = (RECORD_FIXED_BYTES as u64)\n        .checked_add(name_length as u64)\n        .and_then(|value| value.checked_add(payload_len));\n    if total_len < RECORD_FIXED_BYTES as u64\n        || declared != Some(total_len)\n        || name_length == 0\n        || name_length > MAX_REGION_NAME_BYTES\n    {\n        return handle_bad_length(file, offset, physical_len, total_len, remaining);\n    }\n    if total_len > remaining {","sourceCodeStart":342,"sourceCodeEnd":378,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-storage/src/volume/hosted/recover.rs#L342-L378","documentation":"read_header reads the fixed-size record prefix and requires it to begin with RECORD_MAGIC. A mismatch means the bytes at the given offset are not the start of a valid volume record, so recovery/commit decoding cannot proceed and raises InvalidData with the offending offset included in the message.","triggerScenarios":"recover_from_headers or read_commit walking to an offset whose bytes don't start with RECORD_MAGIC — a corrupted record, a torn/partial write, following a stale next-record pointer, or reading a volume written by an incompatible version.","commonSituations":"Power loss / crash mid-write leaving a half-written record; the recovery pointer referencing a record that was later overwritten; bit rot on the storage device; version skew between the writer's record layout and the reader.","solutions":["Use the reported offset to inspect the file (`dd`/`xxd` around that offset) and confirm the corruption extent.","Let recovery stop at the last valid commit — treat records after the bad offset as lost and rely on the last consistent snapshot.","Verify writer/reader astrid-storage versions match.","Restore the volume from backup if corruption precedes the last valid commit."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"match recover_container(&mut file) {\n    Err(e) if e.kind() == io::ErrorKind::InvalidData\n        && e.to_string().starts_with(\"invalid Astrid volume record magic\") => {\n        eprintln!(\"record corruption: {e}; falling back to last valid commit\");\n        /* open read-only at last valid snapshot or restore from backup */\n    }\n    other => other,\n}","preventionTips":["Ensure clean shutdown (sync_all) so no torn records are left behind.","Run recovery promptly after a crash instead of appending to a suspect stream.","Monitor storage health (bit rot) and keep volume backups.","Keep record format versions aligned between writer and reader."],"tags":["storage","corruption","recovery","records"],"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"}