Skip to content

copyObject throws Access Denied if source key is not present #6523

@marcindyelp

Description

@marcindyelp

Checkboxes for prior research

Describe the bug

To perform copyObject according to aws docs, you need s3:GetObject and s3:PutObject permissions. That works fine with only those permissions.
Problem: If source key (file) does not exist in the bucket, API throws misleading error:
AccessDenied: User: arn:aws:sts:#########r is not authorized to perform: s3:ListBucket on resource: "arn:aws:s3:::my_bucket because no identity-based policy allows the s3:ListBucket action
Obviously s3:ListBucket is not needed. Error thrown should be 'key not present, check source...' or anything like that.

Regression Issue

  • Select this option if this issue appears to be a regression.

SDK version number

@aws-sdk/[email protected], CopyObjectCommand

Which JavaScript Runtime is this issue in?

Node.js

Details of the browser/Node.js/ReactNative version

node 18.19.0

Reproduction Steps

delete the source file

Observed Behavior

AccessDenied: User: arn:aws:sts:#########r is not authorized to perform: s3:ListBucket on resource: "arn:aws:s3:::my_bucket because no identity-based policy allows the s3:ListBucket action

Expected Behavior

Obviously s3:ListBucket is not needed. Error thrown should be 'key not present, check source...' or anything like that.

Possible Solution

change the error/response from API to user

Additional Information/Context

No response

Metadata

Metadata

Assignees

Labels

bugThis issue is a bug.closing-soonThis issue will automatically close in 4 days unless further comments are made.p3This is a minor priority issueservice-apiThis issue is due to a problem in a service API, not the SDK implementation.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions