{"record":{"id":"29701583d4f650c5","repo":"databendlabs/databend","slug":"missing-bucket-in-url","errorCode":null,"errorMessage":"missing bucket in URL","messagePattern":"missing bucket in URL","errorType":"validation","errorClass":"InvalidInput","httpStatus":null,"severity":"error","filePath":"src/common/storage/src/operator.rs","lineNumber":784,"sourceCode":"\n        let scheme = url.scheme();\n\n        // Handle file:// and memory:// URIs which don't have a host/bucket\n        let is_local_scheme = matches!(scheme, \"file\" | \"memory\" | \"\");\n        let (bucket, relative_path_pos) = if is_local_scheme {\n            // For file:// URIs, the path starts after \"file://\"\n            let prefix_len = if location.starts_with(\"file://\") {\n                7 // \"file://\".len()\n            } else if location.starts_with(\"memory://\") {\n                9 // \"memory://\".len()\n            } else {\n                0\n            };\n            (None, prefix_len)\n        } else {\n            let bucket = url\n                .host_str()\n                .ok_or_else(|| Error::new(ErrorKind::InvalidInput, \"missing bucket in URL\"))?;\n            let prefix = format!(\"{}://{}/\", scheme, bucket);\n            let relative_path_pos = if location.starts_with(&prefix) {\n                prefix.len()\n            } else {\n                url.scheme().len() + 3 + bucket.len() + 1\n            };\n            (Some(bucket), relative_path_pos)\n        };\n\n        let mut opendal_config: std::collections::HashMap<String, String> =\n            std::collections::HashMap::new();\n\n        if let Some(bucket) = bucket {\n            opendal_config.insert(\"bucket\".to_string(), bucket.to_string());\n        }\n\n        self.validate_s3_credentials()?;\n","sourceCodeStart":766,"sourceCodeEnd":802,"githubUrl":"https://github.com/databendlabs/databend/blob/288d84d76e20a2f8f7173bda9691eb6ece301aa9/src/common/storage/src/operator.rs#L766-L802","documentation":"After parsing the location URL, build_operator extracts the host component as the storage bucket. For non-local schemes (anything besides file, memory, or empty), a URL without a host has no bucket to address, so the code returns InvalidInput 'missing bucket in URL'.","triggerScenarios":"get_operator_path with a location like 's3:///path/to/table' or 's3://' where url::Url parses successfully but host_str() returns None (empty host).","commonSituations":"Table locations built by string concatenation where the bucket part was empty; environment-driven configs where a bucket variable was unset; metadata from a misconfigured catalog whose warehouse URI lost its bucket; file/memory locations mistakenly passed with a remote scheme.","solutions":["Include the bucket as the URL host in the location, e.g. 's3://my-bucket/path' instead of 's3:///path'.","Check the variable/template that produces the location for an empty bucket value.","Use a local scheme (file:// or memory://) only when you actually intend local/memory storage, not for remote buckets."],"exampleFix":"// before\nlet location = format!(\"s3://{bucket}/{path}\"); // bucket == \"\"\n// after\nassert!(!bucket.is_empty(), \"S3 bucket must be set\");\nlet location = format!(\"s3://{bucket}/{path}\");","handlingStrategy":"validation","validationCode":"let u = url::Url::parse(location)?;\nif u.scheme() != \"file\" && u.scheme() != \"memory\" && u.host_str().map_or(true, str::is_empty) {\n    return Err(anyhow!(\"location {location:?} has no bucket host\"));\n}","typeGuard":null,"tryCatchPattern":"match file_io.get_operator_path(location) {\n    Err(e) if e.message() == \"missing bucket in URL\" => {\n        bail!(\"table location {location:?} must include the bucket, e.g. s3://bucket/path\");\n    }\n    other => other,\n}","preventionTips":["Check that bucket variables are non-empty before interpolating them into URIs.","Use format!(\"{}://{}/{}\", scheme, bucket, path) with an asserted non-empty bucket.","Never strip the host from remote URIs when normalizing paths."],"tags":["storage","iceberg","s3","url"],"backgroundTag":"missing-required-argument","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"}