{"record":{"id":"272b03d6a6a29263","repo":"juicedata/juicefs","slug":"failed-to-create-bucket-s-s-previous-error-s","errorCode":null,"errorMessage":"Failed to create bucket %s: %s, previous error: %s\nPlease create bucket %s manually, then format again.","messagePattern":"Failed to create bucket (.+?): (.+?), previous error: (.+?)\nPlease create bucket (.+?) manually, then format again\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/format.go","lineNumber":341,"sourceCode":"var letters = []rune(\"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\")\n\nfunc randSeq(n int) string {\n\tb := make([]rune, n)\n\tr := rand.New(rand.NewSource(time.Now().UnixNano()))\n\tfor i := range b {\n\t\tb[i] = letters[r.Intn(len(letters))]\n\t}\n\treturn string(b)\n}\n\nfunc doTesting(ctx context.Context, store object.ObjectStorage, key string, data []byte) error {\n\tif err := store.Put(ctx, key, bytes.NewReader(data)); err != nil {\n\t\tif strings.Contains(strings.ToLower(err.Error()), \"denied\") {\n\t\t\treturn fmt.Errorf(\"Failed to put: %s\", err)\n\t\t}\n\t\tif err2 := store.Create(ctx); err2 != nil {\n\t\t\tif strings.Contains(err.Error(), \"NoSuchBucket\") {\n\t\t\t\treturn fmt.Errorf(\"Failed to create bucket %s: %s, previous error: %s\\nPlease create bucket %s manually, then format again.\",\n\t\t\t\t\tstore, err2, err, store)\n\t\t\t} else {\n\t\t\t\treturn fmt.Errorf(\"Failed to create bucket %s: %s, previous error: %s\",\n\t\t\t\t\tstore, err2, err)\n\t\t\t}\n\t\t}\n\t\tif err := store.Put(ctx, key, bytes.NewReader(data)); err != nil {\n\t\t\treturn fmt.Errorf(\"Failed to put: %s\", err)\n\t\t}\n\t}\n\t// GLACIER storage class doesn't allow read after write\n\tif _, ok := ctx.Value(object.TierKey{}).(uint8); ok {\n\t\treturn nil\n\t}\n\tp, err := store.Get(ctx, key, 0, -1)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Failed to get: %s\", err)\n\t}","sourceCodeStart":323,"sourceCodeEnd":359,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/cmd/format.go#L323-L359","documentation":"The initial Put failed with a NoSuchBucket error, and the automatic bucket-creation attempt (store.Create) also failed. JuiceFS tried to create the missing bucket for you but could not, and it instructs you to create the bucket manually before formatting again.","triggerScenarios":"`juicefs format` with a bucket name/endpoint that doesn't exist, where the credentials also lack s3:CreateBucket permission, region is wrong (creation against wrong region endpoint), or the provider does not support auto-creation (e.g. some S3-compatible stores).","commonSituations":"Typo in bucket name; AWS account at a different region than the endpoint; IAM user with object permissions but not bucket-management permissions; OSS/COS endpoints mismatching the bucket region.","solutions":["Create the bucket manually with the provider CLI: `aws s3 mb s3://mybucket --region us-east-1`","Correct the bucket name and endpoint in the --storage-url / format options","Grant s3:CreateBucket permission if the bucket should be auto-created","Verify the region: a bucket created in us-west-2 cannot be used via a us-east-1 endpoint in some providers"],"exampleFix":"// before\njuicefs format ... s3://mybucket\n// Failed to create bucket...\n// after\naws s3 mb s3://mybucket --region us-east-1\njuicefs format ... s3://mybucket","handlingStrategy":"validation","validationCode":"// pre-check bucket existence\n// aws s3api head-bucket --bucket mybucket || aws s3 mb s3://mybucket","typeGuard":"func isNoSuchBucket(err error) bool {\n    return err != nil && strings.Contains(err.Error(), \"NoSuchBucket\")\n}","tryCatchPattern":"err := doTesting(ctx, store, key, data)\nif err != nil && strings.Contains(err.Error(), \"Please create bucket\") {\n    // create bucket manually, then re-run format\n}","preventionTips":["Create the bucket before running juicefs format","Double-check bucket name spelling and region in the storage URL","Grant s3:CreateBucket if auto-creation is desired","Match the endpoint to the bucket's region"],"tags":["object-storage","s3","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-14T00:17:10.932Z"}