argoproj/argo-workflows · error
failed to automatically create bucket %s when it's not prese
Error message
failed to automatically create bucket %s when it's not present: %w
What it means
Raised in Save when createBucketIfNotPresent is true, the bucket does not exist, and osscli.CreateBucket fails to create it. Commonly a permissions problem (RAM user lacks oss:PutBucket), a bucket-name conflict (name globally taken in the region or owned by another account), or invalid bucket configuration (region, name characters, storage class).
Source
Thrown at workflow/artifacts/oss/oss.go:246
isDir, err := file.IsDirectory(path)
if err != nil {
logger.WithError(err).Warn(ctx, "Failed to test if path is a directory")
return false, nil
}
bucketName := outputArtifact.OSS.Bucket
err = setBucketLogging(osscli, bucketName)
if err != nil {
return !isTransientOSSErr(ctx, err), err
}
if outputArtifact.OSS.CreateBucketIfNotPresent {
exists, existsErr := osscli.IsBucketExist(bucketName)
if existsErr != nil {
return !isTransientOSSErr(ctx, existsErr), fmt.Errorf("failed to check if bucket %s exists: %w", bucketName, existsErr)
}
if !exists {
err = osscli.CreateBucket(bucketName)
if err != nil {
return !isTransientOSSErr(ctx, err), fmt.Errorf("failed to automatically create bucket %s when it's not present: %w", bucketName, err)
}
}
}
bucket, err := osscli.Bucket(bucketName)
if err != nil {
return !isTransientOSSErr(ctx, err), err
}
objectName := outputArtifact.OSS.Key
if outputArtifact.OSS.LifecycleRule != nil {
err = setBucketLifecycleRule(osscli, outputArtifact.OSS)
if err != nil {
return !isTransientOSSErr(ctx, err), err
}
}
if isDir {
if err = putDirectory(ctx, bucket, objectName, path); err != nil {
logger.WithError(err).Warn(ctx, "failed to put directory")
return !isTransientOSSErr(ctx, err), errView on GitHub (pinned to 35bff19146)
Solutions
- Inspect the wrapped OSS error code: BucketAlreadyExists means pick a new globally-unique bucket name; AccessDenied means grant oss:PutBucket to the RAM user/role.
- Pre-create the bucket with ossutil mb or the console and set createBucketIfNotPresent: false.
- Verify the endpoint/region matches the intended bucket location (creationRegion).
- Check account bucket quota (default 100 per region) if the error is TooManyBuckets.
- Validate the bucket name (3-63 chars, lowercase letters/numbers/hyphens).
Example fix
// before (workflow spec) oss: bucket: my-bucket createBucketIfNotPresent: true // after (pre-create outside the workflow) # ossutil mb oss://my-argo-artifacts-bucket-2026 --region oss-cn-hangzhou oss: bucket: my-argo-artifacts-bucket-2026 createBucketIfNotPresent: false
Defensive patterns
Strategy: validation
Validate before calling
// pre-create and verify before workflows run
cli, _ := oss.New(endpoint, ak, sk)
if ok, _ := cli.IsBucketExist(bucketName); !ok {
if err := cli.CreateBucket(bucketName); err != nil {
panic(fmt.Sprintf("create %s now, not during workflow: %v", bucketName, err))
}
} Type guard
func isBucketNameTaken(err error) bool {
se, ok := err.(oss.ServiceError)
return ok && (se.Code == "BucketAlreadyExists" || se.Code == "BucketAlreadyOwnedByYou")
} Try / catch
if err := driver.Save(ctx, path, artifact); err != nil {
if strings.Contains(err.Error(), "failed to automatically create bucket") {
var se oss.ServiceError
if errors.As(err, &se) && (se.Code == "BucketAlreadyExists" || se.Code == "AccessDenied") {
// pick unique name or grant oss:PutBucket — retries won't help
}
}
} Prevention
- Use globally-unique, environment-prefixed bucket names (org-team-purpose-region).
- Disable createBucketIfNotPresent in shared/production accounts and create buckets via Terraform/IaC.
- Keep account bucket count under quota; monitor if many ephemeral buckets are created.
- Match endpoint region to intended bucket location.
When it happens
Trigger: Save of an output artifact with createBucketIfNotPresent: true; IsBucketExist returned false; CreateBucket returns an error such as AccessDenied, BucketAlreadyExists, TooManyBuckets, or InvalidBucketName.
Common situations: Bucket name already registered by another Aliyun account (OSS names are globally unique per region); RAM policy not updated to allow PutBucket; exceeding the account's bucket quota; region mismatch between endpoint and desired bucket location.
Related errors
- failed to check if bucket %s exists: %w
- mkdir %s error: %w
- failed to test if %s/%s is a directory: %w
- failed get directory: %w
- failed to configure bucket logging: %w
AI-assisted analysis of argoproj/argo-workflows@35bff19146 (2026-09-03).
Data as JSON: /api/errors/8fff844701d65ada.
Report an issue: GitHub.