{"record":{"id":"0eca7ecc4fc1108c","repo":"juicedata/juicefs","slug":"can-t-find-bucket-s-with-provided-key-id","errorCode":null,"errorMessage":"can't find bucket %s with provided Key ID","messagePattern":"can't find bucket (.+?) with provided Key ID","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/object/b2.go","lineNumber":187,"sourceCode":"\t\tKeyID:          keyID,\n\t\tApplicationKey: applicationKey,\n\t})\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"create B2 client: %s\", err)\n\t}\n\tclient.MaxIdleUploads = 20\n\tbucket, err := client.Bucket(name)\n\tif err != nil {\n\t\tlogger.Warnf(\"access bucket %s: %s\", name, err)\n\t}\n\tif err == nil && bucket == nil {\n\t\tbucket, err = client.CreateBucket(name, \"allPrivate\")\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"create bucket %s: %s\", name, err)\n\t\t}\n\t}\n\tif bucket == nil {\n\t\treturn nil, fmt.Errorf(\"can't find bucket %s with provided Key ID\", name)\n\t}\n\treturn &b2client{bucket: bucket}, nil\n}\n\nfunc init() {\n\tRegister(\"b2\", newB2)\n}\n","sourceCodeStart":169,"sourceCodeEnd":195,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/pkg/object/b2.go#L169-L195","documentation":"Thrown when the B2 client could neither fetch nor create the bucket: Bucket(name) returned nil (no error) and the code cannot proceed without a bucket handle. The named bucket does not exist under the credentials provided.","triggerScenarios":"newB2 where client.Bucket(name) returns nil,nil (bucket not visible to this key) and CreateBucket is skipped or not attempted because err != nil from the earlier lookup, leaving bucket nil.","commonSituations":"Bucket name typo; application key restricted to a different bucket (unauthorized buckets are invisible); bucket deleted before mount; bucket lives under a different account than the key.","solutions":["Verify the bucket name exactly (B2 names are case-sensitive and must match).","Confirm the application key is authorized for that bucket (allInKey or the specific bucket).","Check the bucket exists with 'b2 list-buckets'.","Use a master key or generate a key scoped to the correct bucket."],"exampleFix":"// before\nkey scoped to bucket \"old-bucket\", endpoint references \"new-bucket\" -> not found\n// after\ngenerate a key restricted to \"new-bucket\" (or use the account master key) and retry","handlingStrategy":"validation","validationCode":"buckets, _, err := client.ListBuckets()\nif err != nil { return err }\nfound := false\nfor _, b := range buckets { if b.BucketName == name { found = true } }\nif !found { return fmt.Errorf(\"bucket %q not visible to this key\", name) }","typeGuard":null,"tryCatchPattern":"bucket, err := client.Bucket(name)\nif err != nil { return fmt.Errorf(\"lookup failed: %w\", err) }\nif bucket == nil { return fmt.Errorf(\"bucket %q not found or not authorized for this key\", name) }","preventionTips":["List buckets with 'b2 list-buckets' to confirm visibility before mount","Scope application keys to the exact bucket they will use","Keep bucket names in a single source of truth to avoid typos"],"tags":["b2","object-storage","bucket-not-found","permissions"],"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"}