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

  1. Pass create=true if the region should be created on first open
  2. Call volume.create_region(&region, false) before opening
  3. Verify the region name matches the one used at creation exactly
  4. 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(&region)? {
    volume.create_region(&region, 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

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


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(&region, false)?;
        } else if !volume.region_exists(&region)? {
            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(&region, true)?;
        Ok(Self {
            volume,
            region,

View on GitHub (pinned to affd8760f4)