quickwit-oss/quickwit · error · StorageError

missing file `{}`

Error message

missing file `{}`

What it means

`RamStorage::file_num_bytes` looks the path up in the in-memory file map and returns the byte length; if the key is missing it raises a NotFound StorageError with "missing file `{path}`". This is the RAM-storage analogue of stat failing with ENOENT.

Source

Thrown at quickwit/quickwit-storage/src/ram_storage.rs:154

    }

    async fn get_all(&self, path: &Path) -> StorageResult<OwnedBytes> {
        let payload_bytes = self.get_data(path).await.ok_or_else(|| {
            StorageErrorKind::NotFound
                .with_error(anyhow::anyhow!("failed to find dest_path {:?}", path))
        })?;
        Ok(payload_bytes)
    }

    fn uri(&self) -> &Uri {
        &self.uri
    }

    async fn file_num_bytes(&self, path: &Path) -> StorageResult<u64> {
        if let Some(file_bytes) = self.files.read().await.get(path) {
            Ok(file_bytes.len() as u64)
        } else {
            let err = anyhow::anyhow!("missing file `{}`", path.display());
            Err(StorageErrorKind::NotFound.with_error(err))
        }
    }
}

/// Builder to create a prepopulated [`RamStorage`]. This is mostly useful for tests.
#[derive(Default)]
pub struct RamStorageBuilder {
    files: HashMap<PathBuf, OwnedBytes>,
}

impl RamStorageBuilder {
    /// Adds a new file into the [`RamStorageBuilder`].
    pub fn put(mut self, path: &str, payload: &[u8]) -> Self {
        self.files
            .insert(PathBuf::from(path), OwnedBytes::new(payload.to_vec()));
        self
    }

View on GitHub (pinned to a39730c5cd)

Solutions

  1. Insert the file into the RamStorage (builder/`put`) before querying its size
  2. Match the exact path used at insertion time (watch for prefix differences)
  3. Handle StorageErrorKind::NotFound if the file may legitimately be absent
  4. Verify no concurrent delete removed the entry between operations

Example fix

// before
let size = ram.file_num_bytes(&Path::from("/missing")).await?;
// after
let ram = RamStorage::builder().put("/missing", bytes).build();
let size = ram.file_num_bytes(&Path::from("/missing")).await?;
Defensive patterns

Strategy: try-catch

Validate before calling

if !ram_storage.exists(&path).await? { return Err(anyhow::anyhow!("not seeded: {}", path)); }

Try / catch

match ram_storage.file_num_bytes(&path).await {
    Ok(size) => use(size),
    Err(e) if e.kind() == StorageErrorKind::NotFound => seed_or_default(path),
    Err(e) => return Err(e.into()),
}

Prevention

When it happens

Trigger: Calling `Storage::file_num_bytes` on a RamStorage for a path never inserted or already deleted.

Common situations: Tests asserting on nonexistent files; checking the size of a file after a delete/bulk_delete; path spelling or prefix mismatch between write and size-check code.

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


AI-assisted analysis of quickwit-oss/quickwit@a39730c5cd (2026-09-08). Data as JSON: /api/errors/e10f8bcc070262c9. Report an issue: GitHub.