fixermark
fixermark

Reputation: 1260

How to catch failed S3 copyObject with 200 OK result in AWSJavaScriptSDK

Documentation on the S3.copyObject method in AWSJavaScriptSDK indicates the following:

A copy request might return an error when Amazon S3 receives the copy request or while Amazon S3 is copying the files. If the error occurs before the copy operation starts, you receive a standard Amazon S3 error. If the error occurs during the copy operation, the error response is embedded in the 200 OK response. This means that a 200 OK response can contain either a success or an error. Design your application to parse the contents of the response and handle it appropriately.

However, no example is given of what that failure might look like, and the types associated with copyObject in the aws-sdk Node library (i.e. CopyObjectResult and S3.Types.CopyObjectOutput) suggest that there isn't a place for a failed copy to be reported in a success response.

Does anyone know how to interpret this documentation? What is an example of a copy operation failing while returning a 200 OK to copyObject, and how would the caller know?

Upvotes: 8

Views: 3160

Answers (1)

fixermark
fixermark

Reputation: 1260

The SDK itself massages 200 status OK responses into errors for specific API calls, including copyObject.

As of this commit , the operations completeMultipartUpload, copyObject, and uploadPartCopy are flagged as able to return a status code 200 that is actually an error, and there is a handler to coerce those responses into error responses.

Upvotes: 6

Related Questions