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

AioJSONParser can't read the initial response from the stream #872

Closed
bashalex opened this issue Jul 10, 2021 · 6 comments · Fixed by #873
Closed

AioJSONParser can't read the initial response from the stream #872

bashalex opened this issue Jul 10, 2021 · 6 comments · Fixed by #873

Comments

@bashalex
Copy link

bashalex commented Jul 10, 2021

Describe the bug

The library fails to read (seems like any) Stream response.

In particular, AioJSONParser fails to read the initial response from the stream.

When AioJSONParser.parse() is called, internally it calls _handle_event_stream() which tries to call the get_initial_response() method of the AioEventStream which expectedly fails to execute next(self._event_generator) since it is an Async Generator.

To reproduce, you can call the subscribe_to_shard() method of the Kinesis client:

async with self._session.create_client(
        'kinesis',
        region_name=AWS_REGION_NAME,
        aws_access_key_id=AWS_ACCESS_KEY_ID,
        aws_secret_access_key=AWS_SECRET_ACCESS_KEY,
) as client:
    starting_position = {
        'Type': 'LATEST'
    }
    response = await client.subscribe_to_shard(
        ConsumerARN=CONSUMER_ARN,
        ShardId=SHARD_ID,
        StartingPosition=starting_position
    )

Environment:

  • Python Version: 3.9.5
  • OS name and version: WSL 2 (Ubuntu 18)
  • aiobotocore: 1.3.2
  • botocore: 1.20.106
@thehesiod
Copy link
Collaborator

will look asap

@bashalex
Copy link
Author

Thanks! Here is the stacktrace:

    ...
    response = await client.subscribe_to_shard(
  File "/home/bashalex/.cache/pypoetry/virtualenvs/asset-service-PCliylm9-py3.9/lib/python3.9/site-packages/aiobotocore/client.py", line 141, in _make_api_call
    http, parsed_response = await self._make_request(
  File "/home/bashalex/.cache/pypoetry/virtualenvs/asset-service-PCliylm9-py3.9/lib/python3.9/site-packages/aiobotocore/client.py", line 161, in _make_request
    return await self._endpoint.make_request(operation_model, request_dict)
  File "/home/bashalex/.cache/pypoetry/virtualenvs/asset-service-PCliylm9-py3.9/lib/python3.9/site-packages/aiobotocore/endpoint.py", line 89, in _send_request
    success_response, exception = await self._get_response(
  File "/home/bashalex/.cache/pypoetry/virtualenvs/asset-service-PCliylm9-py3.9/lib/python3.9/site-packages/aiobotocore/endpoint.py", line 122, in _get_response
    success_response, exception = await self._do_get_response(
  File "/home/bashalex/.cache/pypoetry/virtualenvs/asset-service-PCliylm9-py3.9/lib/python3.9/site-packages/aiobotocore/endpoint.py", line 182, in _do_get_response
    parsed_response = parser.parse(
  File "/home/bashalex/.cache/pypoetry/virtualenvs/asset-service-PCliylm9-py3.9/lib/python3.9/site-packages/botocore/parsers.py", line 245, in parse
    parsed = self._do_parse(response, shape)
  File "/home/bashalex/.cache/pypoetry/virtualenvs/asset-service-PCliylm9-py3.9/lib/python3.9/site-packages/botocore/parsers.py", line 778, in _do_parse
    parsed = self._handle_event_stream(response, shape, event_name)
  File "/home/bashalex/.cache/pypoetry/virtualenvs/asset-service-PCliylm9-py3.9/lib/python3.9/site-packages/botocore/parsers.py", line 791, in _handle_event_stream
    event = event_stream.get_initial_response()
  File "/home/bashalex/.cache/pypoetry/virtualenvs/asset-service-PCliylm9-py3.9/lib/python3.9/site-packages/botocore/eventstream.py", line 606, in get_initial_response
    initial_event = next(self._event_generator)
TypeError: 'async_generator' object is not an iterator

@thehesiod
Copy link
Collaborator

unfortunately can't use moto for testing since they don't support the required methods. oo man, this is going to require several patches and increase our footprint even more :(

@thehesiod thehesiod linked a pull request Jul 12, 2021 that will close this issue
@thehesiod
Copy link
Collaborator

@bashalex want to try the linked PR?

@bashalex
Copy link
Author

Wow, that was rapid! Let me check it out.

@bashalex
Copy link
Author

It works now, thanks for the quick resolution!
Looking forward to the PR being merged.

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 a pull request may close this issue.

2 participants