{"record":{"id":"3ce64b4abc3f9252","repo":"juicedata/juicefs","slug":"unable-to-get-endpoint-of-bucket-s-s","errorCode":null,"errorMessage":"Unable to get endpoint of bucket %s: %s","messagePattern":"Unable to get endpoint of bucket (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/object/cos.go","lineNumber":338,"sourceCode":"\nfunc newCOS(endpoint, accessKey, secretKey, token string) (ObjectStorage, error) {\n\tif !strings.Contains(endpoint, \"://\") {\n\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 %s: %s\", endpoint, err)\n\t}\n\thostParts := strings.SplitN(uri.Host, \".\", 2)\n\n\tif accessKey == \"\" {\n\t\taccessKey = os.Getenv(\"COS_SECRETID\")\n\t\tsecretKey = os.Getenv(\"COS_SECRETKEY\")\n\t}\n\n\tif len(hostParts) == 1 {\n\t\tif endpoint, err = autoCOSEndpoint(hostParts[0], accessKey, secretKey, token); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"Unable to get endpoint of bucket %s: %s\", hostParts[0], err)\n\t\t}\n\t\tif uri, err = url.ParseRequestURI(endpoint); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"Invalid endpoint %s: %s\", endpoint, err)\n\t\t}\n\t\tlogger.Debugf(\"Use endpoint %q\", endpoint)\n\t}\n\n\tb := &cos.BaseURL{BucketURL: uri}\n\tclient := cos.NewClient(b, &http.Client{\n\t\tTransport: &cos.AuthorizationTransport{\n\t\t\tSecretID:     accessKey,\n\t\t\tSecretKey:    secretKey,\n\t\t\tSessionToken: token,\n\t\t\tTransport:    httpClient.Transport,\n\t\t},\n\t})\n\tclient.UserAgent = UserAgent\n\tdisableChecksum := strings.EqualFold(uri.Query().Get(\"disable-checksum\"), \"true\")","sourceCodeStart":320,"sourceCodeEnd":356,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/pkg/object/cos.go#L320-L356","documentation":"When the endpoint is just a bucket name, newCOS calls autoCOSEndpoint to resolve the bucket's regional endpoint via the COS API. Any error from that lookup (auth failure, API error, bucket not found) is wrapped as \"Unable to get endpoint of bucket %s: %s\".","triggerScenarios":"newCOS called with hostParts length 1 (bare bucket name) and autoCOSEndpoint returning an error — invalid credentials, network failure, ListBucket API error, or bucket not in the account.","commonSituations":"Wrong or expired COS_SECRETID/COS_SECRETKEY; network egress blocked to COS; bucket name typo or bucket owned by another account; missing appid suffix in the bucket name.","solutions":["Read the wrapped inner error (%s suffix) to identify the root cause (auth vs network vs not-found).","Provide the full regional endpoint explicitly to skip auto-detection: https://<bucket>.cos.<region>.myqcloud.com.","Verify COS_SECRETID/COS_SECRETKEY (or passed accessKey/secretKey) are valid and have ListBucket permission.","Check network connectivity to cos.myqcloud.com from the host."],"exampleFix":"// before\nnewCOS(\"mybucket\", wrongAk, sk, \"\")\n// after\nnewCOS(\"https://mybucket-appid.cos.ap-guangzhou.myqcloud.com\", ak, sk, \"\")","handlingStrategy":"fallback","validationCode":"// if credentials or network may be unavailable, avoid auto-detection\nif bucketOnlyEndpoint {\n    endpoint = fmt.Sprintf(\"https://%s.cos.%s.myqcloud.com\", bucket, region)\n}","typeGuard":null,"tryCatchPattern":"obj, err := object.CreateStorage(\"cos\", bucketName, ak, sk, \"\")\nif err != nil && strings.Contains(err.Error(), \"Unable to get endpoint\") {\n    obj, err = object.CreateStorage(\"cos\", explicitRegionalEndpoint, ak, sk, \"\")\n}","preventionTips":["Configure full regional endpoints to avoid the ListBucket round-trip","Validate COS credentials before startup","Read the wrapped inner error to distinguish auth vs network causes"],"tags":["cos","tencent","endpoint","api"],"backgroundTag":"api-request-failed","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"}