{"record":{"id":"c0d047f03afd2fe6","repo":"juicedata/juicefs","slug":"cannot-get-location-of-bucket-s-q","errorCode":null,"errorMessage":"cannot get location of bucket %s: %q","messagePattern":"cannot get location of bucket (.+?): %q","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/object/obs.go","lineNumber":406,"sourceCode":"\turi, err := url.ParseRequestURI(endpoint)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"invalid endpoint %s: %q\", endpoint, err)\n\t}\n\thostParts := strings.SplitN(uri.Host, \".\", 2)\n\tbucketName := hostParts[0]\n\tif len(hostParts) > 1 {\n\t\tendpoint = fmt.Sprintf(\"%s://%s\", uri.Scheme, hostParts[1])\n\t}\n\n\tif accessKey == \"\" {\n\t\taccessKey = os.Getenv(\"HWCLOUD_ACCESS_KEY\")\n\t\tsecretKey = os.Getenv(\"HWCLOUD_SECRET_KEY\")\n\t}\n\n\tvar region string\n\tif len(hostParts) == 1 {\n\t\tif endpoint, err = autoOBSEndpoint(bucketName, accessKey, secretKey, token); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"cannot get location of bucket %s: %q\", bucketName, err)\n\t\t}\n\t\tif !strings.HasPrefix(endpoint, \"http\") {\n\t\t\tendpoint = fmt.Sprintf(\"%s://%s\", uri.Scheme, endpoint)\n\t\t}\n\t} else {\n\t\tregion = strings.Split(hostParts[1], \".\")[1]\n\t}\n\n\t// Use proxy setting from environment variables: HTTP_PROXY, HTTPS_PROXY, NO_PROXY\n\tif uri, err = url.ParseRequestURI(endpoint); err != nil {\n\t\treturn nil, fmt.Errorf(\"invalid endpoint %s: %q\", endpoint, err)\n\t}\n\tproxyURL, err := httpproxy.FromEnvironment().ProxyFunc()(uri)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"get proxy url for endpoint: %s error: %q\", endpoint, err)\n\t}\n\tvar urlString string\n\tif proxyURL != nil {","sourceCodeStart":388,"sourceCodeEnd":424,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/pkg/object/obs.go#L388-L424","documentation":"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.","triggerScenarios":"Endpoint like 'https://mybucket' with no region component, plus either a ListBuckets API failure (auth/network) or the bucket not appearing in the listing.","commonSituations":"Users specifying just the bucket name expecting auto-discovery; credentials lacking ListBuckets permission; network/proxy blocking the OBS global endpoint; bucket in another account.","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"],"exampleFix":"// before\nobject.CreateStorage(\"obs\", \"mybucket\", ak, sk, \"\")\n// after\nobject.CreateStorage(\"obs\", \"mybucket.obs.cn-north-1.myhuaweicloud.com\", ak, sk, \"\")","handlingStrategy":"fallback","validationCode":"if !strings.Contains(endpoint, \".\") { endpoint = bucket + \".obs.\" + region + \".myhuaweicloud.com\" }","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"cannot get location of bucket\") {\n\t// retry with explicit regional endpoint\n}","preventionTips":["Prefer fully qualified regional endpoints over bare bucket names","Ensure credentials can call ListBuckets","Verify network access to the OBS global endpoint"],"tags":["obs","bucket","region","auto-discovery"],"backgroundTag":"resource-not-found","analyzedSha":"c9a67b23e8e08ec23ec331aa6f1675e2319e921c","analyzedAt":"2026-09-06T17:55:48.476Z","contentChangedAt":"2026-09-06T17:55:48.476Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}