{"record":{"id":"d900598454c0b26f","repo":"juicedata/juicefs","slug":"create-bucket-s-s","errorCode":null,"errorMessage":"create bucket %s: %s","messagePattern":"create bucket (.+?): (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/object/b2.go","lineNumber":183,"sourceCode":"\thostParts := strings.Split(uri.Host, \".\")\n\tname := hostParts[0]\n\t// TODO: set UserAgent once kothar/go-backblaze supports http.Client injection\n\tclient, err := backblaze.NewB2(backblaze.Credentials{\n\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":165,"sourceCodeEnd":195,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/pkg/object/b2.go#L165-L195","documentation":"Returned by newB2 when the referenced bucket cannot be found and creating it (as private) also fails. Access warnings precede it; the wrapped error explains why bucket creation was rejected (credentials without create permission, or invalid name).","triggerScenarios":"newB2 where the bucket does not exist under the authorized account and creation fails — name already taken by another account, name violates B2 bucket naming rules, or the key lacks write capability.","commonSituations":"Application key restricted to a different bucket; desired bucket name already registered globally in B2; invalid bucket name (length/case/characters); key without writeFiles/writeBuckets capability.","solutions":["Check the bucket name is valid per B2 rules (4-63 chars, lowercase letters/digits/hyphens).","Create the bucket manually via 'b2 create-bucket' or the web console, then retry.","Ensure the application key has write capability and is not bucket-restricted to another bucket.","Pick a different (globally unique) bucket name if it is taken."],"exampleFix":"// before\nbucket name: \"Ab\"   (invalid/short, creation fails)\n// after\nbucket name: \"my-juicefs-bucket-01\"","handlingStrategy":"validation","validationCode":"var bucketNameRE = regexp.MustCompile(`^[a-z0-9-]{4,63}$`)\nif !bucketNameRE.MatchString(name) { return fmt.Errorf(\"invalid B2 bucket name %q\", name) }","typeGuard":null,"tryCatchPattern":"bucket, err := client.CreateBucket(name, \"allPrivate\")\nif err != nil {\n    return fmt.Errorf(\"cannot create bucket %s (taken, invalid name, or key lacks write caps): %w\", name, err)\n}","preventionTips":["Create buckets in advance via console/CLI instead of auto-creating","Use lowercase alphanumeric names with hyphens, 4-63 chars","Use keys with write capability for auto-creation paths"],"tags":["b2","object-storage","bucket-creation","permissions"],"backgroundTag":"api-error-response","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"}