copyObject: what does a 200 status but failed operation look like?

0

Our team is using the AWSJavaScriptSDK. According to the documentation https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#copyObject-property:

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 TypeScript file of 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?

Edited by: Mark T Tomczak on Apr 19, 2020 9:08 AM

Edited by: Mark T Tomczak on Apr 19, 2020 9:08 AM

Edited by: Mark T Tomczak on Apr 19, 2020 9:09 AM

已提問 4 年前檢視次數 438 次
1 個回答
0

Got bored, spelunked in the source code of the library itself, found the answer to my own question. ;)

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

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

[1]: https://github.com/aws/aws-sdk-js/commit/347f2d9b11deea1fd09bff960245801d47edbd5c
[2]: https://github.com/aws/aws-sdk-js/blob/dfb49100f7db707a2479726f911ca31443f5a861/lib/services/s3.js#L13-L15
[3]: https://github.com/aws/aws-sdk-js/blob/dfb49100f7db707a2479726f911ca31443f5a861/lib/services/s3.js#L652

已回答 4 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南