{"record":{"id":"3cc0a5c42b7be881","repo":"apache/beam","slug":"error-copying-object-s-v","errorCode":null,"errorMessage":"error copying object %s: %v","messagePattern":"error copying object (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/io/filesystem/s3/s3.go","lineNumber":227,"sourceCode":"func (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\n\tparams := &s3.CopyObjectInput{\n\t\tBucket:     aws.String(destBucket),\n\t\tCopySource: aws.String(copySource),\n\t\tKey:        aws.String(destKey),\n\t}\n\tif _, err = f.client.CopyObject(ctx, params); err != nil {\n\t\treturn fmt.Errorf(\"error copying object %s: %v\", oldpath, err)\n\t}\n\n\treturn nil\n}\n\n// Compile time check for interface implementations.\nvar (\n\t_ filesystem.LastModifiedGetter = (*fs)(nil)\n\t_ filesystem.Remover            = (*fs)(nil)\n\t_ filesystem.Copier             = (*fs)(nil)\n)\n","sourceCodeStart":209,"sourceCodeEnd":239,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/io/filesystem/s3/s3.go#L209-L239","documentation":"Returned by fs.Copy when the AWS SDK CopyObject call fails. The message reports the source path while wrapping the underlying AWS error. Causes include missing s3:GetObject on the source or s3:PutObject on the destination, missing CopySource URI-encoding, or size limits (single CopyObject fails for objects >5 GB).","triggerScenarios":"Calling fs.Copy on valid URIs where IAM denies the copy, the source key does not exist, CopySource is not URL-encoded (keys with spaces/special chars), or the object exceeds 5 GB.","commonSituations":"Cross-account copies without proper bucket policy grants; keys with special characters not encoded; large files needing multipart copy; wrong region endpoints.","solutions":["Ensure IAM allows s3:GetObject on source and s3:PutObject (plus s3:GetObject for ACL copying) on destination.","Verify the source object exists and that the key is URI-encoded when forming CopySource.","For objects over 5 GB, use multipart upload/copy instead of single CopyObject.","Inspect the wrapped AWS error code and retry transient failures."],"exampleFix":"// before: unencoded CopySource\ncopySource := fmt.Sprintf(\"%s/%s\", sourceBucket, sourceKey)\n\n// after: URL-encode the key per S3 CopySource requirements\ncopySource := fmt.Sprintf(\"%s/%s\", sourceBucket, url.PathEscape(sourceKey))","handlingStrategy":"retry","validationCode":"validS3URI(oldpath); validS3URI(newpath)\n// for keys with spaces/special chars, verify encoding:\nif strings.ContainsAny(sourceKey, \" \") { copySource = sourceBucket + \"/\" + url.PathEscape(sourceKey) }","typeGuard":null,"tryCatchPattern":"if _, err = f.client.CopyObject(ctx, params); err != nil {\n    if isTransientAWSError(err) { /* backoff + retry */ }\n    switch {\n    case strings.Contains(err.Error(), \"AccessDenied\"):\n        return ErrPermission\n    case strings.Contains(err.Error(), \"NoSuchKey\"):\n        return ErrSourceMissing\n    case strings.Contains(err.Error(), \"InvalidRequest\"):\n        return ErrObjectTooLarge // >5GB needs multipart copy\n    }\n    return err\n}","preventionTips":["URI-encode the key portion of CopySource (spaces must be encoded, prefix with bucket/key).","Grant s3:GetObject on source and s3:PutObject on destination to the job role.","Use multipart copy for objects larger than 5 GB.","Ensure source and destination bucket regions are reachable from the worker."],"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"}