{"record":{"id":"9f02d848b6cf2d4b","repo":"apache/beam","slug":"error-deleting-object-s-v","errorCode":null,"errorMessage":"error deleting object %s: %v","messagePattern":"error deleting object (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/io/filesystem/s3/s3.go","lineNumber":202,"sourceCode":"\t\treturn time.Time{}, fmt.Errorf(\"error getting metadata for object %s: %v\", filename, err)\n\t}\n\n\treturn aws.ToTime(output.LastModified), err\n}\n\n// Remove removes the file from the filesystem.\nfunc (f *fs) Remove(ctx context.Context, filename string) error {\n\tbucket, key, err := parseURI(filename)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error parsing S3 uri %s: %v\", filename, err)\n\t}\n\n\tparams := &s3.DeleteObjectInput{\n\t\tBucket: aws.String(bucket),\n\t\tKey:    aws.String(key),\n\t}\n\tif _, err = f.client.DeleteObject(ctx, params); err != nil {\n\t\treturn fmt.Errorf(\"error deleting object %s: %v\", filename, err)\n\t}\n\n\treturn nil\n}\n\n// Copy copies the file from the old path to the new path.\nfunc (f *fs) Copy(ctx context.Context, oldpath, newpath string) error {\n\tsourceBucket, sourceKey, err := parseURI(oldpath)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error parsing S3 source uri %s: %v\", oldpath, err)\n\t}\n\n\tcopySource := fmt.Sprintf(\"%s/%s\", sourceBucket, sourceKey)\n\tdestBucket, destKey, err := parseURI(newpath)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error parsing S3 destination uri %s: %v\", newpath, err)\n\t}\n","sourceCodeStart":184,"sourceCodeEnd":220,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/io/filesystem/s3/s3.go#L184-L220","documentation":"Returned by fs.Remove when the AWS SDK DeleteObject call fails. The error wraps the underlying AWS error with the filename. Common causes include missing delete permissions, a non-existent bucket, or network/API failures.","triggerScenarios":"Calling fs.Remove(ctx, filename) on a valid s3:// path where the IAM role lacks s3:DeleteObject, the bucket is in another account/region, or the S3 service returns an error.","commonSituations":"Read-only credentials used by a cleanup job; bucket name typo; bucket versioning/retention policies blocking deletion; transient network failures.","solutions":["Grant the caller IAM permission s3:DeleteObject on the bucket/key prefix.","Verify the bucket exists and matches the configured region/credentials.","Check for S3 Object Lock, retention policies, or bucket policies denying deletion.","Retry on transient errors; inspect the wrapped cause for the exact API error code."],"exampleFix":"// before: single attempt, no retry\nif _, err = f.client.DeleteObject(ctx, params); err != nil {\n    return fmt.Errorf(\"error deleting object %s: %v\", filename, err)\n}\n\n// after: distinguish not-found and retry transient errors\nif _, err = f.client.DeleteObject(ctx, params); err != nil {\n    var nfe *types.NoSuchBucket\n    if errors.As(err, &nfe) { return nil }\n    if aerr, ok := err.(awserr.Error); ok && aerr.RetryableError() != nil { /* backoff + retry */ }\n    return fmt.Errorf(\"error deleting object %s: %w\", filename, err)\n}","handlingStrategy":"retry","validationCode":"if !strings.HasPrefix(filename, \"s3://\") { return fmt.Errorf(\"not an s3 URI: %s\", filename) }\n// confirm delete permission is configured for the job's IAM role out-of-band","typeGuard":null,"tryCatchPattern":"err := fsys.Remove(ctx, filename)\nif err != nil {\n    if isTransientAWSError(err) { /* backoff and retry Remove */ }\n    if strings.Contains(err.Error(), \"AccessDenied\") { return ErrPermissionDenied }\n    return err\n}","preventionTips":["Grant s3:DeleteObject on the exact prefixes cleanup jobs operate on.","Remember Remove is idempotent-safe; treat NoSuchKey/404 as success where appropriate.","Watch for Object Lock / retention policies that silently block deletes.","Use exponential backoff for throttling (SlowDown) errors."],"tags":["aws","s3","network","storage"],"backgroundTag":"http-error-response","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}