{"record":{"id":"de3715b490677d3c","repo":"juicedata/juicefs","slug":"bucket-q-doesn-t-exist","errorCode":null,"errorMessage":"bucket %q doesn't exist","messagePattern":"bucket %q doesn't exist","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/object/cos.go","lineNumber":318,"sourceCode":"\t\t\tSecretID:     accessKey,\n\t\t\tSecretKey:    secretKey,\n\t\t\tSessionToken: token,\n\t\t},\n\t})\n\tclient.UserAgent = UserAgent\n\ts, _, err := client.Service.Get(ctx)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tfor _, b := range s.Buckets {\n\t\t// fmt.Printf(\"%#v\\n\", b)\n\t\tif b.Name == bucketName {\n\t\t\treturn fmt.Sprintf(\"https://%s.cos.%s.myqcloud.com\", b.Name, b.Region), nil\n\t\t}\n\t}\n\n\treturn \"\", fmt.Errorf(\"bucket %q doesn't exist\", bucketName)\n}\n\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 {","sourceCodeStart":300,"sourceCodeEnd":336,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/pkg/object/cos.go#L300-L336","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nnewCOS(\"mybucket\", ak, sk, \"\") // auto-detect fails\n// after\nnewCOS(\"https://mybucket-appid.cos.ap-guangzhou.myqcloud.com\", ak, sk, \"\")","handlingStrategy":"validation","validationCode":"// ensure the bucket name includes the appid suffix and skip auto-detect when unsure\nif !strings.Contains(bucketName, \"-\") {\n    // pass full regional endpoint instead\n}","typeGuard":null,"tryCatchPattern":"obj, err := object.CreateStorage(\"cos\", endpoint, ak, sk, \"\")\nif err != nil && strings.Contains(err.Error(), \"doesn't exist\") {\n    // fall back to explicit regional endpoint\n    obj, err = object.CreateStorage(\"cos\", fullRegionalURL, ak, sk, \"\")\n}","preventionTips":["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"],"tags":["cos","tencent","endpoint","bucket"],"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"}