{"record":{"id":"4548a19c31f145dd","repo":"argoproj/argo-workflows","slug":"failed-to-list-directory-w","errorCode":null,"errorMessage":"failed to list directory: %w","messagePattern":"failed to list directory: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"workflow/artifacts/s3/s3.go","lineNumber":398,"sourceCode":"\t\t\ts3cli, err := s3Driver.newClient(ctx)\n\t\t\tif err != nil {\n\t\t\t\treturn !isTransientS3Err(ctx, err), fmt.Errorf(\"failed to create new S3 client: %w\", err)\n\t\t\t}\n\t\t\tdone, files, err = listObjects(ctx, s3cli, artifact)\n\t\t\treturn done, err\n\t\t})\n\n\treturn files, err\n}\n\n// listObjects returns the files inside the directory represented by the Artifact\n// returns true if success or can't be retried (non-transient error)\n// returns false if it can be retried (transient error)\nfunc listObjects(ctx context.Context, s3cli Client, artifact *wfv1.Artifact) (bool, []string, error) {\n\tvar files []string\n\tfiles, err := s3cli.ListDirectory(artifact.S3.Bucket, artifact.S3.Key)\n\tif err != nil {\n\t\treturn !isTransientS3Err(ctx, err), files, fmt.Errorf(\"failed to list directory: %w\", err)\n\t}\n\tlog := logging.RequireLoggerFromContext(ctx)\n\tlog.WithFields(logging.Fields{\"bucket\": artifact.S3.Bucket, \"key\": artifact.S3.Key, \"files\": files}).Debug(ctx, \"successfully listing S3 directory\")\n\n\tif len(files) == 0 {\n\t\tdirectoryExists, err := s3cli.KeyExists(artifact.S3.Bucket, artifact.S3.Key)\n\t\tif err != nil {\n\t\t\treturn !isTransientS3Err(ctx, err), files, fmt.Errorf(\"failed to check if key %s exists from bucket %s: %w\", artifact.S3.Key, artifact.S3.Bucket, err)\n\t\t}\n\t\tif !directoryExists {\n\t\t\treturn true, files, argoerrs.New(argoerrs.CodeNotFound, fmt.Sprintf(\"no key found of name %s\", artifact.S3.Key))\n\t\t}\n\t}\n\treturn true, files, nil\n}\n\nfunc (s3Driver *ArtifactDriver) IsDirectory(ctx context.Context, artifact *wfv1.Artifact) (bool, error) {\n\ts3cli, err := s3Driver.newClient(ctx)","sourceCodeStart":380,"sourceCodeEnd":416,"githubUrl":"https://github.com/argoproj/argo-workflows/blob/35bff19146f5a6ada77468c431f2624bd577e373/workflow/artifacts/s3/s3.go#L380-L416","documentation":"Wraps a failure from s3cli.ListDirectory when loading an S3 artifact directory. Called inside the retry backoff of listS3Artifact; transient errors are retried, non-transient ones fail the load. Means the S3 API call enumerating objects under the artifact key prefix failed.","triggerScenarios":"listObjects calls s3cli.ListDirectory(bucket, key) and Minio returns an error: bucket does not exist, access denied to list, network error, or invalid key prefix.","commonSituations":"Bucket typo in artifact spec; IAM policy lacks s3:ListBucket; S3 endpoint unreachable from pod; loading an artifact whose bucket was deleted.","solutions":["Check the wrapped cause for the concrete S3 error (NoSuchBucket, AccessDenied, timeout)","Verify the artifact's s3.bucket and key are correct and the bucket exists","Grant the artifact credentials s3:ListBucket (and GetObject) on the bucket","Confirm endpoint connectivity from the cluster/pod"],"exampleFix":"// before (IAM)\n// no ListBucket permission\n// after\n{\"Effect\":\"Allow\",\"Action\":[\"s3:ListBucket\",\"s3:GetObject\"],\"Resource\":[\"arn:aws:s3:::my-bucket\",\"arn:aws:s3:::my-bucket/*\"]}","handlingStrategy":"retry","validationCode":"aws --endpoint-url $ENDPOINT s3api head-bucket --bucket $BUCKET\naws --endpoint-url $ENDPOINT s3api list-objects-v2 --bucket $BUCKET --prefix $KEY --max-items 1","typeGuard":null,"tryCatchPattern":"// wrap load and inspect cause\nfiles, err := ctx.LoadArtifact(artifact)\nif err != nil {\n  var ae smithy.APIError\n  if errors.As(errors.Unwrap(err), &ae) && ae.ErrorCode() == \"AccessDenied\" { fixIAM() }\n}","preventionTips":["Grant s3:ListBucket + s3:GetObject to artifact credentials","Validate bucket name and key prefix in the artifact spec","Prefer referencing artifacts by name from prior steps rather than hand-typed buckets/keys"],"tags":["s3","artifacts","list","permissions"],"backgroundTag":"s3-list-directory-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"}