{"record":{"id":"e10f8bcc070262c9","repo":"quickwit-oss/quickwit","slug":"missing-file-e10f8b","errorCode":null,"errorMessage":"missing file `{}`","messagePattern":"missing file `(.+?)`","errorType":"exception","errorClass":"StorageError","httpStatus":null,"severity":"error","filePath":"quickwit/quickwit-storage/src/ram_storage.rs","lineNumber":154,"sourceCode":"    }\n\n    async fn get_all(&self, path: &Path) -> StorageResult<OwnedBytes> {\n        let payload_bytes = self.get_data(path).await.ok_or_else(|| {\n            StorageErrorKind::NotFound\n                .with_error(anyhow::anyhow!(\"failed to find dest_path {:?}\", path))\n        })?;\n        Ok(payload_bytes)\n    }\n\n    fn uri(&self) -> &Uri {\n        &self.uri\n    }\n\n    async fn file_num_bytes(&self, path: &Path) -> StorageResult<u64> {\n        if let Some(file_bytes) = self.files.read().await.get(path) {\n            Ok(file_bytes.len() as u64)\n        } else {\n            let err = anyhow::anyhow!(\"missing file `{}`\", path.display());\n            Err(StorageErrorKind::NotFound.with_error(err))\n        }\n    }\n}\n\n/// Builder to create a prepopulated [`RamStorage`]. This is mostly useful for tests.\n#[derive(Default)]\npub struct RamStorageBuilder {\n    files: HashMap<PathBuf, OwnedBytes>,\n}\n\nimpl RamStorageBuilder {\n    /// Adds a new file into the [`RamStorageBuilder`].\n    pub fn put(mut self, path: &str, payload: &[u8]) -> Self {\n        self.files\n            .insert(PathBuf::from(path), OwnedBytes::new(payload.to_vec()));\n        self\n    }","sourceCodeStart":136,"sourceCodeEnd":172,"githubUrl":"https://github.com/quickwit-oss/quickwit/blob/a39730c5cdcd1a4fe798403737ae293999ea21f8/quickwit/quickwit-storage/src/ram_storage.rs#L136-L172","documentation":"`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.","triggerScenarios":"Calling `Storage::file_num_bytes` on a RamStorage for a path never inserted or already deleted.","commonSituations":"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.","solutions":["Insert the file into the RamStorage (builder/`put`) before querying its size","Match the exact path used at insertion time (watch for prefix differences)","Handle StorageErrorKind::NotFound if the file may legitimately be absent","Verify no concurrent delete removed the entry between operations"],"exampleFix":"// before\nlet size = ram.file_num_bytes(&Path::from(\"/missing\")).await?;\n// after\nlet ram = RamStorage::builder().put(\"/missing\", bytes).build();\nlet size = ram.file_num_bytes(&Path::from(\"/missing\")).await?;","handlingStrategy":"try-catch","validationCode":"if !ram_storage.exists(&path).await? { return Err(anyhow::anyhow!(\"not seeded: {}\", path)); }","typeGuard":null,"tryCatchPattern":"match ram_storage.file_num_bytes(&path).await {\n    Ok(size) => use(size),\n    Err(e) if e.kind() == StorageErrorKind::NotFound => seed_or_default(path),\n    Err(e) => return Err(e.into()),\n}","preventionTips":["Insert the file before querying size in tests","Use one shared RamStorage instance for the whole test to avoid divergent maps","Handle NotFound when the file may have been deleted","Compare paths with the exact form used at insertion (watch root prefix)"],"tags":["ram-storage","not-found","size","tests"],"backgroundTag":"file-not-found","analyzedSha":"a39730c5cdcd1a4fe798403737ae293999ea21f8","analyzedAt":"2026-09-08T13:19:37.784Z","contentChangedAt":"2026-09-08T13:19:37.784Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}