{"record":{"id":"4b1c71d571397c11","repo":"quickwit-oss/quickwit","slug":"uri-uri-is-not-a-valid-file-uri","errorCode":null,"errorMessage":"URI `{uri}` is not a valid file URI","messagePattern":"URI `(.+?)` is not a valid file URI","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"quickwit/quickwit-storage/src/lib.rs","lineNumber":109,"sourceCode":"#[cfg(feature = \"integration-testsuite\")]\npub use self::test_suite::{\n    storage_test_multi_part_upload, storage_test_single_part_upload, storage_test_suite,\n    test_write_and_bulk_delete,\n};\npub use self::timeout_and_retry_storage::TimeoutAndRetryStorage;\npub use crate::error::{\n    BulkDeleteError, DeleteFailure, StorageError, StorageErrorKind, StorageResolverError,\n    StorageResult,\n};\n\n/// Loads an entire local or remote file into memory.\npub async fn load_file(\n    storage_resolver: &StorageResolver,\n    uri: &Uri,\n) -> anyhow::Result<OwnedBytes> {\n    let parent = uri\n        .parent()\n        .ok_or_else(|| anyhow::anyhow!(\"URI `{uri}` is not a valid file URI\"))?;\n    let storage = storage_resolver.resolve(&parent).await?;\n    let file_name = uri\n        .file_name()\n        .ok_or_else(|| anyhow::anyhow!(\"URI `{uri}` is not a valid file URI\"))?;\n    let bytes = storage.get_all(file_name).await?;\n    Ok(bytes)\n}\n\n// this function isn't meant to be called, just to break compilation if\n// serde_json::Map is an ordered map and not a btree map\n#[allow(dead_code)]\n#[cfg(not(any(test, feature = \"testsuite\", feature = \"integration-testsuite\")))]\nunsafe fn serde_json_preserve_order_canary(\n    val: serde_json::Map<String, serde_json::Value>,\n) -> std::collections::BTreeMap<String, serde_json::Value> {\n    use std::mem::transmute as assert_serde_json__preserve_order__disabled;\n    unsafe { assert_serde_json__preserve_order__disabled(val) }\n}","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/quickwit-oss/quickwit/blob/a39730c5cdcd1a4fe798403737ae293999ea21f8/quickwit/quickwit-storage/src/lib.rs#L91-L127","documentation":"load_file splits the URI into a parent directory (to resolve a storage) and a file name (to fetch). If uri.parent() returns None — the URI has no separable parent, e.g. a bare scheme-less or root-less URI — the function cannot determine which storage to use and fails with this anyhow error.","triggerScenarios":"Calling load_file with a URI whose parent() is None, such as \"file.txt\" (no scheme/separator), an empty URI, or \"s3://\" with no path component. Reached from create_index_cli, update_index_cli, load_node_config, create_source_cli, and update_source_cli when a --config or index-config URI is malformed.","commonSituations":"Passing a bare relative file name on the CLI instead of a full URI like file:///path/to/config.yaml or /abs/path/config.yaml; forgetting the scheme or path when pointing at an S3-hosted config; shell variable expansion leaving the URI empty.","solutions":["Pass a fully-qualified URI including at least a parent directory, e.g. file:///etc/quickwit/config.yaml or s3://bucket/path/config.yaml.","If using a local path, prefix it with file:// or use an absolute path so parent() resolves.","Echo the URI variable before invoking the CLI to catch empty or truncated values from shell expansion.","Validate the URI with Uri::parse or similar before calling load_file programmatically."],"exampleFix":"// before\nlet config = load_file(&resolver, &\"quickwit.yaml\".into()).await?;\n// after\nlet uri = Uri::parse(\"file:///etc/quickwit/quickwit.yaml\")?;\nlet config = load_file(&resolver, &uri).await?;","handlingStrategy":"validation","validationCode":"if uri.as_str().is_empty() || !uri.as_str().contains('/') {\n    anyhow::bail!(\"URI `{}` must include a parent directory, e.g. file:///path/config.yaml\", uri);\n}","typeGuard":"fn has_parent(uri: &Uri) -> bool {\n    uri.parent().is_some()\n}","tryCatchPattern":"let config = load_file(&resolver, &uri).await.map_err(|e| {\n    anyhow::anyhow!(\"failed to load config from `{uri}`: {e} (use a full URI like file:///etc/quickwit/quickwit.yaml)\")\n})?;","preventionTips":["Always pass fully-qualified URIs (file:// or s3://bucket/key) to CLIs, never bare file names.","Echo shell variables used for URIs to catch empty expansions.","Validate URIs with Uri::parse before calling load_file programmatically."],"tags":["storage","uri","configuration"],"backgroundTag":"invalid-url-format","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"}