{"record":{"id":"7bca64964a29bc62","repo":"astrid-runtime/astrid","slug":"region-name-too-long","errorCode":null,"errorMessage":"region name too long","messagePattern":"region name too long","errorType":"exception","errorClass":"io::Error","httpStatus":null,"severity":"error","filePath":"crates/astrid-storage/src/volume/hosted/mod.rs","lineNumber":112,"sourceCode":"            .field(\"path\", &self.path)\n            .finish_non_exhaustive()\n    }\n}\nimpl HostedFileVolume {\n    fn append(\n        state: &mut ContainerState,\n        operation: Operation,\n        region: &VolumeRegion,\n        offset: u64,\n        payload: &[u8],\n    ) -> io::Result<(u64, u64)> {\n        let next_sequence = state\n            .sequence\n            .checked_add(1)\n            .ok_or_else(|| io::Error::other(\"Astrid volume sequence exhausted\"))?;\n        let name = region.as_str().as_bytes();\n        let name_len = u16::try_from(name.len())\n            .map_err(|_| io::Error::new(io::ErrorKind::InvalidInput, \"region name too long\"))?;\n        let payload_len = u64::try_from(payload.len())\n            .map_err(|_| io::Error::other(\"volume record payload is too large\"))?;\n        let total_len = u64::try_from(RECORD_FIXED_BYTES)\n            .ok()\n            .and_then(|fixed| fixed.checked_add(u64::from(name_len)))\n            .and_then(|total| total.checked_add(payload_len))\n            .ok_or_else(|| io::Error::other(\"volume record length overflow\"))?;\n        let mut hasher = blake3::Hasher::new_derive_key(\"astrid volume record v1\");\n        hasher.update(&next_sequence.to_le_bytes());\n        hasher.update(&[operation as u8]);\n        hasher.update(&name_len.to_le_bytes());\n        hasher.update(&offset.to_le_bytes());\n        hasher.update(&payload_len.to_le_bytes());\n        hasher.update(name);\n        hasher.update(payload);\n        let checksum = *hasher.finalize().as_bytes();\n\n        // A footer occupies the old valid-end until the next append. Truncate","sourceCodeStart":94,"sourceCodeEnd":130,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-storage/src/volume/hosted/mod.rs#L94-L130","documentation":"Bounds guard in HostedFileVolume::append: the region name's byte length exceeded u16 range, so it cannot be recorded in the container state's region table and the append is refused with this io error.","triggerScenarios":"Calling append() on a HostedFileVolume with a region whose name exceeds 65535 bytes, e.g. programmatically generated names built by concatenating keys/paths.","commonSituations":"Using file paths, URLs, or user identifiers verbatim as region names; name-collision avoidance schemes that keep appending suffixes until the name is enormous.","solutions":["Shorten region names to <= 65535 bytes (far less in practice)","Hash long identifiers (e.g. SHA-256 hex) and use the digest as the region name","Validate name length before creating the region, failing early with a clearer app-level message","Restructure data to use a short region plus keys inside the payload rather than encoding everything in the name"],"exampleFix":"// before\nlet region = VolumeRegion::new(&format!(\"{}\", giant_user_path))?;\nvolume.append(&region, payload)?;\n// after\nlet digest = sha256(giant_user_path.as_bytes());\nlet region = VolumeRegion::new(&hex_encode(digest))?; // 64 bytes\nvolume.append(&region, payload)?;","handlingStrategy":"validation","validationCode":"fn name_fits(name: &str) -> bool { name.as_bytes().len() <= u16::MAX as usize }\nassert!(name_fits(&region_name), \"region name exceeds 65535 bytes\");","typeGuard":"fn short_region(name: &str) -> Option<VolumeRegion> {\n    if name.as_bytes().len() <= u16::MAX as usize { VolumeRegion::new(name).ok() } else { None }\n}","tryCatchPattern":"match volume.append(&region, payload) {\n    Err(e) if e.kind() == std::io::ErrorKind::InvalidInput => {\n        let hashed = hash_name(region.as_str());\n        volume.append(&VolumeRegion::new(&hashed)?, payload)\n    }\n    other => other,\n}","preventionTips":["Hash long identifiers instead of using them verbatim as names","Enforce a much smaller app-level name limit (e.g. 255 bytes)","Never build region names by unbounded concatenation","Add length checks at the boundary where names enter the system"],"tags":["validation","storage","limits"],"backgroundTag":"value-out-of-range","analyzedSha":"affd8760f44190dbdfbec23403f4c4b642c33112","analyzedAt":"2026-09-09T21:28:12.402Z","contentChangedAt":"2026-09-09T21:28:12.402Z","schemaVersion":2},"datasetVersion":"2026-09-17T20:17:13.540Z"}