juicedata/juicefs · error
cannot get location of bucket %s: %q
Error message
cannot get location of bucket %s: %q
What it means
If the endpoint host has no region (only a bucket name), newOBS resolves the region via autoOBSEndpoint; any failure there (ListBuckets error or bucket not found) is re-wrapped as 'cannot get location of bucket <name>: <cause>'. The root cause is in the quoted %q.
Source
Thrown at pkg/object/obs.go:406
uri, err := url.ParseRequestURI(endpoint)
if err != nil {
return nil, fmt.Errorf("invalid endpoint %s: %q", endpoint, err)
}
hostParts := strings.SplitN(uri.Host, ".", 2)
bucketName := hostParts[0]
if len(hostParts) > 1 {
endpoint = fmt.Sprintf("%s://%s", uri.Scheme, hostParts[1])
}
if accessKey == "" {
accessKey = os.Getenv("HWCLOUD_ACCESS_KEY")
secretKey = os.Getenv("HWCLOUD_SECRET_KEY")
}
var region string
if len(hostParts) == 1 {
if endpoint, err = autoOBSEndpoint(bucketName, accessKey, secretKey, token); err != nil {
return nil, fmt.Errorf("cannot get location of bucket %s: %q", bucketName, err)
}
if !strings.HasPrefix(endpoint, "http") {
endpoint = fmt.Sprintf("%s://%s", uri.Scheme, endpoint)
}
} else {
region = strings.Split(hostParts[1], ".")[1]
}
// Use proxy setting from environment variables: HTTP_PROXY, HTTPS_PROXY, NO_PROXY
if uri, err = url.ParseRequestURI(endpoint); err != nil {
return nil, fmt.Errorf("invalid endpoint %s: %q", endpoint, err)
}
proxyURL, err := httpproxy.FromEnvironment().ProxyFunc()(uri)
if err != nil {
return nil, fmt.Errorf("get proxy url for endpoint: %s error: %q", endpoint, err)
}
var urlString string
if proxyURL != nil {View on GitHub (pinned to c9a67b23e8)
Solutions
- Read the wrapped cause to distinguish auth failure vs bucket-not-found
- Provide the full regional endpoint to skip auto-discovery (e.g. mybucket.obs.cn-north-1.myhuaweicloud.com)
- Fix credentials or grant ListBuckets permission
- Check network/proxy reachability to obs.myhuaweicloud.com
Example fix
// before
object.CreateStorage("obs", "mybucket", ak, sk, "")
// after
object.CreateStorage("obs", "mybucket.obs.cn-north-1.myhuaweicloud.com", ak, sk, "") Defensive patterns
Strategy: fallback
Validate before calling
if !strings.Contains(endpoint, ".") { endpoint = bucket + ".obs." + region + ".myhuaweicloud.com" } Try / catch
if err != nil && strings.Contains(err.Error(), "cannot get location of bucket") {
// retry with explicit regional endpoint
} Prevention
- Prefer fully qualified regional endpoints over bare bucket names
- Ensure credentials can call ListBuckets
- Verify network access to the OBS global endpoint
When it happens
Trigger: Endpoint like 'https://mybucket' with no region component, plus either a ListBuckets API failure (auth/network) or the bucket not appearing in the listing.
Common situations: Users specifying just the bucket name expecting auto-discovery; credentials lacking ListBuckets permission; network/proxy blocking the OBS global endpoint; bucket in another account.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- bucket %q does not exist
- Failed to create bucket %s: %s, previous error: %s Please cr
- bucket %q doesn't exist
- bucket name required
- unexpected ETag: %s != %s
AI-assisted analysis of juicedata/juicefs@c9a67b23e8 (2026-09-06).
Data as JSON: /api/errors/c0d047f03afd2fe6.
Report an issue: GitHub.