Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle case where S3 returns a 200 error response #298

Merged
merged 2 commits into from
Jun 2, 2014

Conversation

jamesls
Copy link
Member

@jamesls jamesls commented Jun 2, 2014

From http://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectCOPY.html:

There are two opportunities for a copy request to return an error. One
can occur when Amazon S3 receives the copy request and the other can
occur 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. Make sure to design your application to parse the
contents of the response and handle it appropriately.

Operations that need this behavior:

  • CompleteMultipartUpload
  • CopyObject
  • UploadPartCopy

The fix here is to switch the status code to 500, because, for all
intents and purposes, this is an error response. This ensures it
goes through our normal 5xx retry logic and exception handling/raising
code.

cc @danielgtaylor

jamesls added 2 commits June 2, 2014 12:49
From http://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectCOPY.html:

There are two opportunities for a copy request to return an error. One
can occur when Amazon S3 receives the copy request and the other can
occur 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. Make sure to design your application to parse the
contents of the response and handle it appropriately.

Operations that need this behavior:

- CompleteMultipartUpload
- CopyObject
- UploadPartCopy

The fix here is to switch the status code to 500, because, for all
intents and purposes, this is an error response.  This ensures it
goes through our normal 5xx retry logic and exception handling/raising
code.
s3_200_handler = names.index('check_for_200_error')
general_retry_handler = names.index('RetryHandler')
self.assertTrue(s3_200_handler < general_retry_handler,
"S3 200 error handler was suppose to be before "
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Grammar: supposed

@danielgtaylor
Copy link
Member

LGTM 🚢-it!

@jamesls jamesls merged commit 26f883c into boto:develop Jun 2, 2014
jamesls added a commit to jamesls/botocore that referenced this pull request Jun 6, 2014
@jamesls jamesls deleted the s3-copy-fix branch June 23, 2014 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants