juicedata/juicefs · error
Unable to get endpoint of bucket %s: %s
Error message
Unable to get endpoint of bucket %s: %s
What it means
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".
Source
Thrown at pkg/object/cos.go:338
func newCOS(endpoint, accessKey, secretKey, token string) (ObjectStorage, error) {
if !strings.Contains(endpoint, "://") {
endpoint = fmt.Sprintf("https://%s", endpoint)
}
uri, err := url.ParseRequestURI(endpoint)
if err != nil {
return nil, fmt.Errorf("Invalid endpoint %s: %s", endpoint, err)
}
hostParts := strings.SplitN(uri.Host, ".", 2)
if accessKey == "" {
accessKey = os.Getenv("COS_SECRETID")
secretKey = os.Getenv("COS_SECRETKEY")
}
if len(hostParts) == 1 {
if endpoint, err = autoCOSEndpoint(hostParts[0], accessKey, secretKey, token); err != nil {
return nil, fmt.Errorf("Unable to get endpoint of bucket %s: %s", hostParts[0], err)
}
if uri, err = url.ParseRequestURI(endpoint); err != nil {
return nil, fmt.Errorf("Invalid endpoint %s: %s", endpoint, err)
}
logger.Debugf("Use endpoint %q", endpoint)
}
b := &cos.BaseURL{BucketURL: uri}
client := cos.NewClient(b, &http.Client{
Transport: &cos.AuthorizationTransport{
SecretID: accessKey,
SecretKey: secretKey,
SessionToken: token,
Transport: httpClient.Transport,
},
})
client.UserAgent = UserAgent
disableChecksum := strings.EqualFold(uri.Query().Get("disable-checksum"), "true")View on GitHub (pinned to c9a67b23e8)
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.
Example fix
// before
newCOS("mybucket", wrongAk, sk, "")
// after
newCOS("https://mybucket-appid.cos.ap-guangzhou.myqcloud.com", ak, sk, "") Defensive patterns
Strategy: fallback
Validate before calling
// if credentials or network may be unavailable, avoid auto-detection
if bucketOnlyEndpoint {
endpoint = fmt.Sprintf("https://%s.cos.%s.myqcloud.com", bucket, region)
} Try / catch
obj, err := object.CreateStorage("cos", bucketName, ak, sk, "")
if err != nil && strings.Contains(err.Error(), "Unable to get endpoint") {
obj, err = object.CreateStorage("cos", explicitRegionalEndpoint, ak, sk, "")
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "API request failed": what wrapped HTTP errors from external APIs mean and how to find the real cause — this error's family across 29 libraries.
Related errors
- bucket %q doesn't exist
- Invalid endpoint %s: %s
- invalid quota command: %d
- fail to auto-detect endpoint: %w
- Invalid endpoint: %v, error: %v
AI-assisted analysis of juicedata/juicefs@c9a67b23e8 (2026-09-06).
Data as JSON: /api/errors/3ce64b4abc3f9252.
Report an issue: GitHub.