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

Decompress gzipped responses #430

Closed
wants to merge 1 commit into from
Closed

Conversation

kalaspuff
Copy link

With aiobotocore 0.5.0 it now also accepts content encoding 'gzip' but doesn't use aiohttp auto_decompress which makes larger responses from AWS end up compressed when passed to botocore parsers.

In my case I got this issue after upgrading to 0.5.0 and when doing a list_topics() call on an SNS aiobotocore client and had lots of topics in the response data.

File ".../lib/python3.5/site-packages/aiobotocore/client.py", line 80, in _make_api_call
  operation_model, request_dict)
File ".../lib/python3.5/site-packages/aiobotocore/endpoint.py", line 264, in _send_request
  request, operation_model, attempts)
File ".../lib/python3.5/site-packages/aiobotocore/endpoint.py", line 356, in _get_response
  response_dict, operation_model.output_shape)
File ".../lib/python3.5/site-packages/botocore/parsers.py", line 212, in parse
  parsed = self._do_parse(response, shape)
File ".../lib/python3.5/site-packages/botocore/parsers.py", line 454, in _do_parse
  root = self._parse_xml_string_to_dom(xml_contents)
File ".../lib/python3.5/site-packages/botocore/parsers.py", line 390, in _parse_xml_string_to_dom
  "invalid XML received:\n%s" % (e, xml_string))
botocore.parsers.ResponseParserError: Unable to parse response (not well-formed (invalid token): line 1, column 0), invalid XML received:
b'\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\x00\xcd\x9aMs\x9b0\x10\x86\xef\xf9\x15\x99 ... \xbf\x01[G\xbd\xdf\x11)\x00\x00'

@codecov
Copy link

codecov bot commented Nov 13, 2017

Codecov Report

Merging #430 into master will decrease coverage by 0.12%.
The diff coverage is 66.66%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #430      +/-   ##
==========================================
- Coverage   87.24%   87.11%   -0.13%     
==========================================
  Files           8        8              
  Lines         486      489       +3     
==========================================
+ Hits          424      426       +2     
- Misses         62       63       +1
Impacted Files Coverage Δ
aiobotocore/endpoint.py 90.24% <66.66%> (-0.44%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 29b2bd1...43b3ccd. Read the comment docs.

@jettify
Copy link
Member

jettify commented Nov 13, 2017

Good catch, previous versions disabled gzip explicitly by adding headers['Accept-Encoding'] = 'identity'. What about streaming output? should we decompress there too?

     elif operation_model.has_streaming_output:
         response_dict['body'] = http_response.raw

@jettify
Copy link
Member

jettify commented Nov 13, 2017

Original issue was crc32 checks on dynamo see comment here https://github.com/aio-libs/aiobotocore/pull/425/files

@thehesiod
Copy link
Collaborator

we need to ensure the following:

  1. making sure that S3 get_object of key that has 'Content-Encoding' metadata set to gzip returns wrong data type #295 works and add unit test
  2. I believe there's a bug in Update aiohttp #425, it should not have removed the identity part yet (see the comment I just added), botocore does not support compressed responses and we need to follow what they do.

@kalaspuff
Copy link
Author

From my own tests it doesn't seem to be conflicting with #295 at least, as it seems to be a streaming output that sets response_dict['body'] to a FlowControlStreamReader instead of bytes data.

@thehesiod
Copy link
Collaborator

@kalaspuff could to try by putting back this line: https://github.com/aio-libs/aiobotocore/pull/425/files#diff-e941ba728e64131911465db18f803157L278 looks like jettify is working on a revert

@jettify
Copy link
Member

jettify commented Nov 14, 2017

@kalaspuff please try https://pypi.python.org/pypi/aiobotocore/0.5.1 feel free to open new issue

@jettify jettify closed this Nov 14, 2017
@kalaspuff
Copy link
Author

@jettify Works like a charm, thanks!

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.

3 participants