juicedata/juicefs · error
bucket %q doesn't exist
Error message
bucket %q doesn't exist
What it means
autoCOSEndpoint lists the buckets in the Tencent COS account (using ListBucket) and looks for one whose name matches bucketName. If no bucket with that name is found, newCOS fails with this error because it cannot determine the bucket's regional endpoint automatically.
Source
Thrown at pkg/object/cos.go:318
SecretID: accessKey,
SecretKey: secretKey,
SessionToken: token,
},
})
client.UserAgent = UserAgent
s, _, err := client.Service.Get(ctx)
if err != nil {
return "", err
}
for _, b := range s.Buckets {
// fmt.Printf("%#v\n", b)
if b.Name == bucketName {
return fmt.Sprintf("https://%s.cos.%s.myqcloud.com", b.Name, b.Region), nil
}
}
return "", fmt.Errorf("bucket %q doesn't exist", bucketName)
}
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 {View on GitHub (pinned to c9a67b23e8)
Solutions
- Verify the bucket name matches exactly (COS bucket names may include the -appid suffix).
- Specify the full endpoint with region explicitly, e.g. https://<bucket>.cos.<region>.myqcloud.com, to skip auto-detection.
- Check the access/secret keys belong to the account owning the bucket and have permission to list buckets.
- Confirm the bucket still exists in the Tencent COS console.
Example fix
// before
newCOS("mybucket", ak, sk, "") // auto-detect fails
// after
newCOS("https://mybucket-appid.cos.ap-guangzhou.myqcloud.com", ak, sk, "") Defensive patterns
Strategy: validation
Validate before calling
// ensure the bucket name includes the appid suffix and skip auto-detect when unsure
if !strings.Contains(bucketName, "-") {
// pass full regional endpoint instead
} Try / catch
obj, err := object.CreateStorage("cos", endpoint, ak, sk, "")
if err != nil && strings.Contains(err.Error(), "doesn't exist") {
// fall back to explicit regional endpoint
obj, err = object.CreateStorage("cos", fullRegionalURL, ak, sk, "")
} Prevention
- Use the full <bucket>-<appid> name in endpoints
- Prefer explicit regional endpoints over auto-detection
- Verify bucket existence and list permissions in the COS console before configuring
When it happens
Trigger: Passing only a bucket name (no region, endpoint with len(hostParts)==1) to newCOS while the account credentials list buckets and none is named bucketName.
Common situations: Typo in bucket name; bucket exists in a different account/credentials; bucket was deleted; credentials lack permission to list or see the bucket; region-specific bucket not visible via ListBucket.
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
- Unable to get endpoint of bucket %s: %s
- Invalid endpoint %s: %s
- Failed to create bucket %s: %s, previous error: %s Please cr
- 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/de3715b490677d3c.
Report an issue: GitHub.