S3 error_code not set (2.5.x)

8 views
Skip to first unread message

Yehuda Sadeh

unread,
Jun 14, 2012, 4:30:33 PM6/14/12
to boto...@googlegroups.com
This is a new issue that started happening on 2.5.0. The problem is
that on 400 responses (from S3), the error_code is not getting set.
The culprit apparently is the following:


@@ -764,6 +780,13 @@ class AWSAuthConnection(object):
msg += 'Retrying in %3.1f seconds' % next_sleep
boto.log.debug(msg)
body = response.read()
+ elif self._credentials_expired(response):
+ # The same request object is used so the security token and
+ # access key params are cleared because they are no longer
+ # valid.
+ request.params = original_params.copy()
+ request.headers = original_headers.copy()
+ self._renew_credentials()
elif response.status < 300 or response.status >= 400 or \
not location:
self.put_http_connection(request.host, self.is_secure,
...
@@ -160,6 +172,19 @@ class S3Connection(AWSAuthConnection):
else:
return ['s3']

+ def _credentials_expired(self, response):
+ if response.status != 400:
+ return False
+ try:
+ for event, node in ElementTree.iterparse(response,
+ events=['start']):
+ if node.tag.endswith('Code'):
+ if node.text == 'ExpiredToken':
+ return True
+ except XMLParseError:
+ return False
+ return False
+

Basically, calling _credentials_expired(response) empties the response
body, and that happens before returning the response. I'm not sure
what would be the best fix for that.

Yehuda

Mitchell Garnaat

unread,
Jun 14, 2012, 7:57:06 PM6/14/12
to boto...@googlegroups.com
Hi -

We are looking into this right now and will hopefully have a solution soon.  I'll update this post with details.

Thanks for reporting this,

Mitch
Reply all
Reply to author
Forward
0 new messages