{"record":{"id":"29384f8b6ddaebdc","repo":"databendlabs/databend","slug":"bendsave-requires-bucket-but-it-s-empty-in-uri","errorCode":null,"errorMessage":"bendsave requires bucket but it's empty in uri: {}","messagePattern":"bendsave requires bucket but it's empty in uri: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/bendsave/src/storage.rs","lineNumber":197,"sourceCode":"\n/// Load epochfs storage from uri.\n///\n/// S3: `s3://bucket/path/to/root/?region=us-east-1&access_key_id=xxx&secret_access_key=xxx`\n/// Fs: `fs://path/to/data`\npub async fn load_bendsave_storage(uri: &str) -> Result<Operator> {\n    let uri = http::Uri::from_str(uri)?;\n    let scheme = uri.scheme_str().unwrap_or_default();\n    let name = uri.host().unwrap_or_default();\n    let path = uri.path();\n    let mut map: HashMap<String, String> =\n        form_urlencoded::parse(uri.query().unwrap_or_default().as_bytes())\n            .map(|(k, v)| (k.to_string(), v.to_lowercase()))\n            .collect();\n\n    let op = match scheme {\n        \"s3\" => {\n            if name.is_empty() {\n                return Err(anyhow!(\n                    \"bendsave requires bucket but it's empty in uri: {}\",\n                    uri.to_string()\n                ));\n            }\n            map.insert(\"bucket\".to_string(), name.to_string());\n            map.insert(\"root\".to_string(), path.to_string());\n            let op = Operator::from_iter::<opendal::services::S3>(map)?.finish();\n            Ok(op)\n        }\n        \"fs\" => {\n            map.insert(\"root\".to_string(), format!(\"/{name}/{path}\"));\n            let op = Operator::from_iter::<opendal::services::Fs>(map)?.finish();\n            Ok(op)\n        }\n        _ => Err(anyhow::anyhow!(\"Unsupported scheme: {}\", scheme)),\n    }?;\n\n    let op = op","sourceCodeStart":179,"sourceCodeEnd":215,"githubUrl":"https://github.com/databendlabs/databend/blob/288d84d76e20a2f8f7173bda9691eb6ece301aa9/src/bendsave/src/storage.rs#L179-L215","documentation":"load_bendsave_storage parses a storage URI (s3://bucket/path/...). For the s3 scheme the bucket (URI authority/name) is mandatory; if it is empty the function refuses to build an Operator and returns this error. Without a bucket, opendal's S3 service cannot address any object.","triggerScenarios":"Calling bendsave backup or restore with a URI like s3:///path/to/root or s3:// (no bucket in the authority), or passing a URI whose name component was stripped before validation.","commonSituations":"Copy-pasting an internal path style URL without the bucket; environment-specific config templating that left the bucket empty; using an fs-style path with the s3 scheme.","solutions":["Include the bucket in the URI authority: s3://my-bucket/path/to/root/?region=...","Re-check the script/config that renders the URI — an empty variable is likely substituted there.","If you intend local filesystem storage, switch the scheme to fs:// instead of s3 without a bucket.","Run the provided test path (test_load_epochfs_storage pattern) or a dry-run with your URI to validate parsing before the real backup/restore."],"exampleFix":"// before\nlet uri = \"s3:///backups/databend/?region=us-east-1\";\n// after\nlet uri = \"s3://my-bucket/backups/databend/?region=us-east-1\";","handlingStrategy":"validation","validationCode":"// Rust: validate the URI before calling backup/restore\nlet u = url::Url::parse(&uri)?;\nif u.scheme() == \"s3\" && u.host_str().unwrap_or(\"\").is_empty() {\n    return Err(\"s3 URI must include a bucket: s3://bucket/path\".into());\n}","typeGuard":null,"tryCatchPattern":"match load_bendsave_storage(&uri, ...) {\n    Ok(op) => op,\n    Err(e) if e.to_string().contains(\"bucket\") => {\n        eprintln!(\"fix URI: s3://<bucket>/<path>?region=...\"); Err(e)\n    }\n    Err(e) => Err(e),\n}","preventionTips":["Always build storage URIs from a template that includes the bucket","Validate URIs at config load time, not at backup time","Keep bucket names in env/config variables with non-empty assertions"],"tags":["rust","s3","config","bendsave"],"backgroundTag":"missing-required-config-field","analyzedSha":"288d84d76e20a2f8f7173bda9691eb6ece301aa9","analyzedAt":"2026-09-11T11:29:36.208Z","contentChangedAt":"2026-09-11T11:29:36.208Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}