astrid-runtime/astrid · error · io::Error
invalid Astrid volume region name
Error message
invalid Astrid volume region name {name:?} What it means
VolumeRegion::new validates the region name and rejects names containing backslashes, control characters, empty path segments, or '.'/'..' segments (plus the earlier checks in the same condition). The name is used as a storage path component, so unsafe values are refused with InvalidInput at construction time.
Solutions
- Sanitize the name: strip control chars and backslashes before constructing
- Reject or normalize input containing '..' or empty segments before calling VolumeRegion::new
- Use only simple relative identifiers like 'alpha/beta' (no leading, trailing, or doubled slashes)
- Validate user-supplied names against a stricter allowlist (alphanumeric, '-', '_', '/')
Example fix
// before
let region = VolumeRegion::new("..\\etc/passwd")?;
// after
let clean = name.replace('\\', "/");
let region = VolumeRegion::new(&clean)?; // now passes validation if segments are safe Defensive patterns
Strategy: validation
Validate before calling
fn valid_region_name(name: &str) -> bool {
!name.contains('\\') && !name.chars().any(char::is_control)
&& name.split('/').all(|p| !p.is_empty() && p != "." && p != "..")
}
assert!(valid_region_name(user_input), "invalid region name"); Type guard
fn as_region(name: &str) -> Option<VolumeRegion> { VolumeRegion::new(name).ok() } Try / catch
match VolumeRegion::new(name) {
Err(e) if e.kind() == std::io::ErrorKind::InvalidInput => return Err(MyError::BadRegion(name.into())),
other => other?,
} Prevention
- Sanitize any user/path-derived input before constructing region names
- Use an allowlist regex like ^[A-Za-z0-9_][A-Za-z0-9_/-]*$
- Never accept Windows-style separators; normalize '\\' to '/' first
- Add unit tests covering '..', '//', backslash and control-char inputs
When it happens
Trigger: Calling VolumeRegion::new with a name containing '\\', any control char, an empty '/'-separated segment ('a//b', leading/trailing '/'), '.', or '..' segments.
Common situations: Deriving region names from user input or file paths without sanitizing; Windows-style paths with backslashes smuggled in; path traversal attempts ('../secret') being blocked by design.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- Astrid volume is not a regular file
- capsule cache path contains unsafe components
- capsule name ' ' is invalid (must match ^[a-z][a-z0-9-]*$)
- durable capsule metadata names a hash for a non-WASM…
- FUSE provider control path is not canonical
AI-assisted analysis of astrid-runtime/astrid@affd8760f4 (2026-09-09).
Data as JSON: /api/errors/84a27361033b5b8c.
Report an issue: GitHub.
Appendix: source
Thrown at crates/astrid-storage/src/volume.rs:46
/// Construct a portable region name.
///
/// # Errors
///
/// Rejects empty names, absolute names, traversal, empty components,
/// backslashes, control characters, and names beyond the format limit.
pub fn new(name: impl Into<String>) -> io::Result<Self> {
let name = name.into();
if name.is_empty()
|| name.len() > MAX_REGION_NAME_BYTES
|| name.starts_with('/')
|| name.ends_with('/')
|| name.contains('\\')
|| name.chars().any(char::is_control)
|| name
.split('/')
.any(|part| part.is_empty() || part == "." || part == "..")
{
return Err(io::Error::new(
io::ErrorKind::InvalidInput,
format!("invalid Astrid volume region name {name:?}"),
));
}
Ok(Self(name))
}
/// Borrow the canonical UTF-8 region name.
#[must_use]
pub fn as_str(&self) -> &str {
&self.0
}
}
/// One path-free namespace mutation committed as part of a volume transaction.
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum VolumeMetadataMutation {
/// Move `source` to an absent `destination`.View on GitHub (pinned to affd8760f4)