astrid-runtime/astrid · error

region.as_str()

Error message

region.as_str()

What it means

write_region_from looks up the target region in the volume's locked state before appending. If state.regions does not contain the requested region, the write is rejected with io::ErrorKind::NotFound whose message is simply the region name — the caller is writing to a region that was never created/opened on this volume.

Solutions

  1. Create or open the region on the volume before writing to it (verify the region-registration API is called first).
  2. Print/compare the exact region name in the error message against the names your code uses — check for typos and case differences.
  3. Confirm the volume instance is the same one where the region was created (not a freshly re-opened volume whose regions weren't loaded).
  4. Check whether the region was deleted or the volume state was reset earlier in the program's lifetime.

Example fix

// before
volume.write_region_from(&region, offset, payload).await?;
// after
if !volume.has_region(&region) {
    volume.create_region(&region).await?;
}
volume.write_region_from(&region, offset, payload).await?;
Defensive patterns

Strategy: validation

Validate before calling

// Rust: check region existence before writing
if !volume.region_names().contains(&region.to_string()) {
    volume.create_region(&region).await?;
}

Try / catch

match volume.write_region_from(&region, offset, payload).await {
    Err(e) if e.kind() == io::ErrorKind::NotFound => {
        volume.create_region(&region).await?;
        volume.write_region_from(&region, offset, payload).await?;
    }
    other => other?,
}

Prevention

When it happens

Trigger: write_region_from is called with a region handle/key absent from volume.state.regions — writing to a region name that was never created, after the region was removed, or on a volume object that hasn't loaded/registered its regions yet.

Common situations: A typo'd or differently-cased region name; the caller skipped the create/open-region step; application logic assumed a region exists after a failed create; regions were dropped on volume reload and the caller reused a stale handle.

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/c66ef063e11b6d83. Report an issue: GitHub.

Appendix: source

Thrown at crates/astrid-storage/src/volume/hosted/stream.rs:34

/// Bounce buffer for payload copy and checksum. Not an operator policy knob:
/// it does not cap blob size or change the record grammar.
const STREAM_BUFFER_BYTES: usize = 64 * 1024;
const RECORD_CHECKSUM_OFFSET: u64 = 43;

pub(super) fn write_region_from(
    volume: &HostedFileVolume,
    region: &VolumeRegion,
    offset: u64,
    payload_len: u64,
    payload: &mut dyn Read,
) -> io::Result<()> {
    if payload_len == 0 {
        return Ok(());
    }
    let mut state = volume.state.lock();
    if !state.regions.contains_key(region) {
        return Err(io::Error::new(io::ErrorKind::NotFound, region.as_str()));
    }
    let end = offset
        .checked_add(payload_len)
        .ok_or_else(|| io::Error::other("volume write range overflow"))?;
    let (physical, _) = append_from(
        &mut state,
        Operation::Write,
        region,
        offset,
        payload_len,
        payload,
    )?;
    let region_state = state
        .regions
        .get_mut(region)
        .ok_or_else(|| io::Error::new(io::ErrorKind::NotFound, region.as_str()))?;
    overlay_extent(&mut region_state.extents, offset, end, physical);
    region_state.length = region_state.length.max(end);

View on GitHub (pinned to affd8760f4)