Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 383
fixermark Avatar asked Apr 09 '20 14:04

fixermark


People also ask

When working with S3 through the API you get an error response as 409 conflict What could be the reason for this?

You are working with the S3 API and receive an error: 409 Conflict. What is a possible cause of this error? You're attempting to delete a bucket without first removing the contents in the bucket. Explanation: A 409 HTTP Status Code can indicate a BucketNotEmpty error code.

Does S3 Putobject overwrite?

If an object already exists in a bucket, the new object will overwrite it because Amazon S3 stores the last write request.

Which HTTP code indicates a successful upload of an object to Amazon S3?

HTTP 200 code indicates a successful write to S3.

Can S3 fail?

Amazon's S3 will occasionally fail with errors during uploads or downloads -- generally "500: Internal Server" errors.

What is copyobject in AWS S3?

The CopyObject operation creates a copy of a file that is already stored in S3. When we tried using it, we consistently got the S3 error AccessDenied: Access Denied.

How do I copy an object from the Amazon S3 Glacier class?

You can't copy an object from the Amazon S3 Glacier storage class. You must first restore the object from Amazon S3 Glacier before you can copy the object. For instructions, see How do I restore an S3 object that has been archived?

What permissions do I need to copy an object from S3?

For example, to copy a specific version of an object, you need the permission for s3:GetObjectVersion in addition to s3:GetObject. If you're copying objects that have object tags, then your IAM identity must have s3:GetObjectTagging and s3:PutObjectTagging permissions.

Does Amazon S3 support copy operations using access points?

Amazon S3 supports copy operations using access points only when the source and destination buckets are in the same AWS Region. Alternatively, for objects accessed through Amazon S3 on Outposts, specify the ARN of the object as accessed in the format arn:aws:s3-outposts:<Region>:<account-id>:outpost/<outpost-id>/object/<key>.


1 Answers

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.

like image 159
fixermark Avatar answered Sep 29 '22 09:09

fixermark