{"record":{"id":"b2f3198f647db7f4","repo":"argoproj/argo-workflows","slug":"failed-to-create-bucket-s-w","errorCode":null,"errorMessage":"failed to create bucket %s: %w","messagePattern":"failed to create bucket (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"workflow/artifacts/s3/s3.go","lineNumber":348,"sourceCode":"\tisDir, err := file.IsDirectory(path)\n\tif err != nil {\n\t\treturn true, fmt.Errorf(\"failed to test if %s is a directory: %w\", path, err)\n\t}\n\tlog := logging.RequireLoggerFromContext(ctx)\n\tcreateBucketIfNotPresent := outputArtifact.S3.CreateBucketIfNotPresent\n\tif createBucketIfNotPresent != nil {\n\t\tlog.WithField(\"bucket\", outputArtifact.S3.Bucket).Info(ctx, \"creating bucket\")\n\t\tmakeBucketErr := s3cli.MakeBucket(outputArtifact.S3.Bucket, minio.MakeBucketOptions{\n\t\t\tRegion:        outputArtifact.S3.Region,\n\t\t\tObjectLocking: outputArtifact.S3.CreateBucketIfNotPresent.ObjectLocking,\n\t\t})\n\t\talreadyExists := bucketAlreadyExistsErr(makeBucketErr)\n\t\tlog.WithField(\"bucket\", outputArtifact.S3.Bucket).\n\t\t\tWithField(\"alreadyExists\", alreadyExists).\n\t\t\tWithError(makeBucketErr).\n\t\t\tInfo(ctx, \"create bucket failed\")\n\t\tif makeBucketErr != nil && !alreadyExists {\n\t\t\treturn !isTransientS3Err(ctx, makeBucketErr), fmt.Errorf(\"failed to create bucket %s: %w\", outputArtifact.S3.Bucket, makeBucketErr)\n\t\t}\n\t}\n\n\tif isDir {\n\t\tif err = s3cli.PutDirectory(outputArtifact.S3.Bucket, outputArtifact.S3.Key, path); err != nil {\n\t\t\treturn !isTransientS3Err(ctx, err), fmt.Errorf(\"failed to put directory: %w\", err)\n\t\t}\n\t} else {\n\t\tif err = s3cli.PutFile(outputArtifact.S3.Bucket, outputArtifact.S3.Key, path); err != nil {\n\t\t\treturn !isTransientS3Err(ctx, err), fmt.Errorf(\"failed to put file: %w\", err)\n\t\t}\n\t}\n\treturn true, nil\n}\n\nfunc bucketAlreadyExistsErr(err error) bool {\n\tresp := &minio.ErrorResponse{}\n\t// https://docs.aws.amazon.com/AmazonS3/latest/API/ErrorResponses.html","sourceCodeStart":330,"sourceCodeEnd":366,"githubUrl":"https://github.com/argoproj/argo-workflows/blob/35bff19146f5a6ada77468c431f2624bd577e373/workflow/artifacts/s3/s3.go#L330-L366","documentation":"When CreateBucketIfNotPresent is set, the driver calls MakeBucket before uploading. This error wraps a MakeBucket failure that was NOT an already-exists error — the bucket could not be created and the upload was aborted.","triggerScenarios":"saveS3Artifact with createBucketIfNotPresent set: s3cli.MakeBucket(bucket, opts) failed for reasons other than BucketAlreadyExists/BucketAlreadyOwnedByYou — permission denied, invalid bucket name, region mismatch, or object-locking unsupported on the endpoint.","commonSituations":"Credentials lacking s3:CreateBucket; bucket name violating S3 naming rules (uppercase, too long); MinIO endpoints not supporting ObjectLocking; region specified that the endpoint doesn't serve; AWS account bucket limits reached.","solutions":["Read the wrapped minio error to get the exact S3 error code","Grant s3:CreateBucket, or pre-create the bucket and remove CreateBucketIfNotPresent","Fix the bucket name to valid S3 naming (lowercase, 3-63 chars)","Disable objectLocking if the target (e.g. MinIO) doesn't support it","Match the region to the endpoint, or omit region for MinIO"],"exampleFix":"# before\ncreateBucketIfNotPresent:\n  objectLocking: true   # unsupported by MinIO\n# after\ncreateBucketIfNotPresent: {}","handlingStrategy":"try-catch","validationCode":"// verify bucket name validity and CreateBucket permission up front\nconst bucketRE = `^[a-z0-9][a-z0-9.-]{1,61}[a-z0-9]$`\nmatched, _ := regexp.MatchString(bucketRE, bucket)\nif !matched { return fmt.Errorf(\"invalid bucket name %q\", bucket) }","typeGuard":null,"tryCatchPattern":"err := s3Driver.Save(ctx, path, art)\nif err != nil && strings.Contains(err.Error(), \"failed to create bucket\") {\n    // pre-create the bucket out-of-band and remove CreateBucketIfNotPresent\n}","preventionTips":["Pre-create buckets via IaC and skip CreateBucketIfNotPresent","Validate bucket names against S3 rules in workflow templates","Don't enable objectLocking unless the backend supports it","Ensure credentials have s3:CreateBucket only where auto-creation is intended"],"tags":["s3","bucket","aws","permissions"],"backgroundTag":"s3-bucket-create-failed","analyzedSha":"35bff19146f5a6ada77468c431f2624bd577e373","analyzedAt":"2026-09-03T19:34:35.908Z","contentChangedAt":"2026-09-03T19:34:35.908Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}