{"record":{"id":"94a284337a9ef43e","repo":"juicedata/juicefs","slug":"fail-to-get-location-of-bucket-q-s","errorCode":null,"errorMessage":"Fail to get location of bucket %q: %s","messagePattern":"Fail to get location of bucket %q: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/object/bos.go","lineNumber":310,"sourceCode":"\t\tendpoint = fmt.Sprintf(\"https://%s\", endpoint)\n\t}\n\turi, err := url.ParseRequestURI(endpoint)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"Invalid endpoint: %v, error: %v\", endpoint, err)\n\t}\n\thostParts := strings.SplitN(uri.Host, \".\", 2)\n\tif len(hostParts) != 2 {\n\t\treturn nil, fmt.Errorf(\"Invalid endpoint: %v\", endpoint)\n\t}\n\tbucketName := hostParts[0]\n\tif accessKey == \"\" {\n\t\taccessKey = os.Getenv(\"BDCLOUD_ACCESS_KEY\")\n\t\tsecretKey = os.Getenv(\"BDCLOUD_SECRET_KEY\")\n\t}\n\tendpoint = hostParts[1]\n\tif hostParts[1] == \"bcebos.com\" {\n\t\tif endpoint, err = autoBOSEndpoint(bucketName, accessKey, secretKey); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"Fail to get location of bucket %q: %s\", bucketName, err)\n\t\t}\n\t}\n\tendpoint = fmt.Sprintf(\"%s://%s\", uri.Scheme, endpoint)\n\tlogger.Debugf(\"Use endpoint: %s\", endpoint)\n\t// endpoint format like https://bj.bcebos.com\n\tbosClient, err := bos.NewClient(accessKey, secretKey, endpoint)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbosClient.Config.Retry = bce.NewNoRetryPolicy()\n\tbosClient.Config.UserAgent = UserAgent\n\treturn &bosclient{bucket: bucketName, c: bosClient}, nil\n}\n\nfunc init() {\n\tRegister(\"bos\", newBOS)\n}\n","sourceCodeStart":292,"sourceCodeEnd":328,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/pkg/object/bos.go#L292-L328","documentation":"When the endpoint's region part is exactly \"bcebos.com\", newBOS calls autoBOSEndpoint to look up the bucket's actual region via the BOS GetBucketLocation API. If that lookup fails (network error, auth failure, bucket missing), construction aborts with this message wrapping the bucket name and error.","triggerScenarios":"Endpoint like \"mybucket.bcebos.com\" plus network failure to bcebos.com, wrong/missing BDCLOUD_ACCESS_KEY/BDCLOUD_SECRET_KEY credentials, or the bucket does not exist / belongs to another account.","commonSituations":"Credentials not set in environment or flags; typo'd bucket name; bucket in a different Baidu Cloud account; corporate firewall blocking the location API call.","solutions":["Set BDCLOUD_ACCESS_KEY and BDCLOUD_SECRET_KEY (or pass accessKey/secretKey explicitly)","Verify the bucket name exists in your Baidu Cloud account","Use a fully qualified regional endpoint (e.g. mybucket.bj.bcebos.com) to skip the location lookup","Check network connectivity/proxy settings to bcebos.com"],"exampleFix":"// before\nexport BDCLOUD_ACCESS_KEY=\nnewBOS(\"mybucket.bcebos.com\", \"\", \"\", \"\")\n// after\nexport BDCLOUD_ACCESS_KEY=AKXXX\nexport BDCLOUD_SECRET_KEY=SKXXX\nnewBOS(\"mybucket.bj.bcebos.com\", \"\", \"\", \"\")","handlingStrategy":"validation","validationCode":"// Go: preflight credentials and bucket before NewBOS\nif os.Getenv(\"BDCLOUD_ACCESS_KEY\") == \"\" || os.Getenv(\"BDCLOUD_SECRET_KEY\") == \"\" {\n    return errors.New(\"BDCLOUD_ACCESS_KEY / BDCLOUD_SECRET_KEY not set\")\n}","typeGuard":null,"tryCatchPattern":"// Go\nobj, err := object.NewBOS(\"mybucket.bcebos.com\", \"\", \"\", \"\")\nif err != nil && strings.Contains(err.Error(), \"Fail to get location\") {\n    // check credentials/bucket, use explicit regional endpoint to skip lookup\n}","preventionTips":["Set BDCLOUD_ACCESS_KEY/BDCLOUD_SECRET_KEY in the environment or flags","Prefer explicit regional endpoints (<bucket>.<region>.bcebos.com) to skip location lookup","Verify bucket existence with the cloud console/CLI before mounting"],"tags":["object-storage","baidu-bos","region-lookup","credentials"],"backgroundTag":"http-error-response","analyzedSha":"c9a67b23e8e08ec23ec331aa6f1675e2319e921c","analyzedAt":"2026-09-06T17:55:48.476Z","contentChangedAt":"2026-09-06T17:55:48.476Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}