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年前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ