astrid-runtime/astrid · error · io::Error
region.as_str()
Error message
region.as_str()
What it means
Opening a volume region in read mode fails with io::ErrorKind::NotFound when the region does not exist and create=false. The error message is the region name itself, so the missing region is identified directly in the error.
Solutions
- Pass create=true if the region should be created on first open
- Call volume.create_region(®ion, false) before opening
- Verify the region name matches the one used at creation exactly
- Check you are pointed at the same volume/storage directory where the region exists
Example fix
// before
let v = VolumeReader::open(volume, VolumeRegion::new("data")?, false)?; // NotFound on fresh volume
// after
let v = VolumeReader::open(volume, VolumeRegion::new("data")?, true)?; // create if missing Defensive patterns
Strategy: try-catch
Validate before calling
if !volume.region_exists(®ion)? {
volume.create_region(®ion, false)?; // or propagate a friendly error
} Type guard
fn region_available(v: &Volume, r: &VolumeRegion) -> bool { v.region_exists(r).unwrap_or(false) } Try / catch
match VolumeReader::open(volume, region.clone(), false) {
Err(e) if e.kind() == std::io::ErrorKind::NotFound => {
eprintln!("region missing: {}", e); VolumeReader::open(volume, region, true)
}
other => other,
} Prevention
- Centralize region-name constants to avoid typos
- Use create=true for first-open semantics in bootstrap code
- Log the region name from the error payload (it is the name itself)
- Verify the storage directory/volume identity matches across processes
When it happens
Trigger: Calling the open constructor with create=false for a region name that was never created (create_region was never called, or a different name was used).
Common situations: Typo or case mismatch in region names; opening a volume from a fresh/other storage directory where the region was never initialized; racing an open before the create path ran.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- source.as_str()
- audit read failed
- destination.as_str()
- invalid Astrid volume record length at
- invalid interior Astrid volume record length at
AI-assisted analysis of astrid-runtime/astrid@affd8760f4 (2026-09-09).
Data as JSON: /api/errors/16419c3f555de2c0.
Report an issue: GitHub.
Appendix: source
Thrown at crates/astrid-storage/src/volume.rs:280
.finish_non_exhaustive()
}
}
impl VolumeFile {
/// Open or create a volume region.
///
/// # Errors
///
/// Returns a namespace or underlying volume error.
pub fn open(
volume: Arc<dyn AstridVolume>,
region: VolumeRegion,
create: bool,
) -> io::Result<Self> {
if create {
volume.create_region(®ion, false)?;
} else if !volume.region_exists(®ion)? {
return Err(io::Error::new(io::ErrorKind::NotFound, region.as_str()));
}
Ok(Self {
volume,
region,
cursor: 0,
})
}
/// Exclusively create a new region.
///
/// # Errors
///
/// Returns `AlreadyExists` or an underlying volume error.
pub fn create_new(volume: Arc<dyn AstridVolume>, region: VolumeRegion) -> io::Result<Self> {
volume.create_region(®ion, true)?;
Ok(Self {
volume,
region,View on GitHub (pinned to affd8760f4)