{"record":{"id":"86500c95189c4d93","repo":"astrid-runtime/astrid","slug":"non-utf-8-region-name","errorCode":null,"errorMessage":"non-UTF-8 region name","messagePattern":"non-UTF-8 region name","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/astrid-storage/src/volume/hosted/recover.rs","lineNumber":388,"sourceCode":"        .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 {\n        return handle_bad_length(file, offset, physical_len, total_len, remaining);\n    }\n    let operation = Operation::decode(fixed[24])?;\n    let name_offset = offset\n        .checked_add(RECORD_FIXED_BYTES as u64)\n        .ok_or_else(|| io::Error::other(\"volume region name offset overflow\"))?;\n    let mut name = vec![0_u8; name_length];\n    read_exact_at(file, name_offset, &mut name)?;\n    let name = String::from_utf8(name)\n        .map_err(|_| io::Error::new(io::ErrorKind::InvalidData, \"non-UTF-8 region name\"))?;\n    let name = VolumeRegion::new(name)?;\n    let payload_offset = name_offset\n        .checked_add(name_length as u64)\n        .ok_or_else(|| io::Error::other(\"volume payload offset overflow\"))?;\n    Ok(Some(RecordHeader {\n        total_len,\n        sequence: u64::from_le_bytes(read_array::<8>(&fixed[16..24])?),\n        operation,\n        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,","sourceCodeStart":370,"sourceCodeEnd":406,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-storage/src/volume/hosted/recover.rs#L370-L406","documentation":"While recovering a hosted volume's region records, the header's variable-length region name bytes are read from disk and validated as UTF-8. The on-disk region name is not valid UTF-8, so the name cannot be turned into a Rust String and mapped to a VolumeRegion. The library treats any corruption or foreign data in the name field as InvalidData rather than panicking.","triggerScenarios":"read_header (called by recover_from_headers and read_commit) parsed a record header whose name_length bytes, read at position_from(header start + RECORD_FIXED_BYTES), decode as invalid UTF-8 — e.g. a corrupted/torn write, a stale or zeroed name region, or a misaligned offset into the record stream.","commonSituations":"A volume file was partially written during a crash (name bytes torn mid-write); the file was corrupted by another tool or truncated/zeroed regions; a caller points recovery at the wrong file or at a file from a different/incompatible volume format, so the header length fields are interpreted incorrectly.","solutions":["Verify the file being recovered is actually an Astrid hosted volume produced by this format version; run recovery against the correct file.","Restore the volume file from backup or snapshot if the name region is corrupted.","Re-run recovery to skip past the corrupt record if the recovery path supports resync, or re-create the volume region and re-write its data.","Check storage medium/filesystem health (fsck) if multiple regions fail with the same error."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// before recovery: sanity-check the file looks like a volume\nlet magic = read_prefix_at(&file, 0)?;\nif magic != EXPECTED_VOLUME_MAGIC { return Err(\"not an Astrid volume file\"); }","typeGuard":null,"tryCatchPattern":"match recover_from_headers(&file) {\n    Err(e) if e.kind() == io::ErrorKind::InvalidData && e.to_string().contains(\"non-UTF-8 region name\") => {\n        // corrupt record: restore from backup or skip/resync recovery\n    }\n    other => other?,\n}","preventionTips":["Always close volumes cleanly so records are never torn mid-write.","Keep backups/snapshots of volume files before running recovery.","Never point recovery at files from a different volume format version.","Monitor storage health (fsck/SMART) where volumes live."],"tags":["storage","io","data-corruption","utf8"],"backgroundTag":"invalid-identifier-format","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"}