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

Subscription.pull() fails with KeyError #899

Closed
campoy opened this issue May 27, 2015 · 2 comments · Fixed by #901
Closed

Subscription.pull() fails with KeyError #899

campoy opened this issue May 27, 2015 · 2 comments · Fixed by #901
Assignees
Labels
api: pubsub Issues related to the Pub/Sub API.

Comments

@campoy
Copy link

campoy commented May 27, 2015

Hi,

My code below fails with a KeyError coming from the library:

  sub = Subscription(SUBSCRIPTION_NAME, Topic(INCOMING_TOPIC_NAME))

  while True:
    try:
      msgs = sub.pull()
      ...
    except:
      msg = 'poll %s: %s' % (SUBSCRIPTION_NAME, traceback.format_exc())
      print msg

Fails with the message:

poll extractors: Traceback (most recent call last):
  File "main.py", line 46, in main
    msgs = sub.pull()
  File "/usr/local/lib/python2.7/dist-packages/gcloud/pubsub/subscription.py", line 176, in pull
    for info in response['receivedMessages']]
KeyError: 'receivedMessages'

This seems like a bug on the pubsub library code.

@dhermes
Copy link
Contributor

dhermes commented May 27, 2015

Indeed it does! Thanks @campoy for filing.

I'm wondering how to reproduce a response without that key, but an easy "fix" (for us) is to just use

response.get('receivedMessages', ())

@tseaver tseaver added the api: pubsub Issues related to the Pub/Sub API. label May 27, 2015
@tseaver
Copy link
Contributor

tseaver commented May 27, 2015

FWIW: this is the hardening I mentioned in #893.

@tseaver tseaver self-assigned this May 29, 2015
tseaver added a commit that referenced this issue May 29, 2015
…receivedMessages

#899: Harden 'Subscription.pull' against missing 'receivedMessages' in response
atulep pushed a commit that referenced this issue Apr 6, 2023
)

* Changes docs for async playback to point to LINEAR16 example
* Updates to client library with FLAC support.
* Changes async examples to flac and updates README
atulep pushed a commit that referenced this issue Apr 6, 2023
)

* Changes docs for async playback to point to LINEAR16 example
* Updates to client library with FLAC support.
* Changes async examples to flac and updates README
atulep pushed a commit that referenced this issue Apr 18, 2023
)

* Changes docs for async playback to point to LINEAR16 example
* Updates to client library with FLAC support.
* Changes async examples to flac and updates README
parthea pushed a commit that referenced this issue Oct 22, 2023
)

* Changes docs for async playback to point to LINEAR16 example
* Updates to client library with FLAC support.
* Changes async examples to flac and updates README
gcf-owl-bot bot added a commit that referenced this issue Apr 30, 2024
Source-Link: googleapis/googleapis@55499b5

Source-Link: googleapis/googleapis-gen@cf5049b
Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWNvbXB1dGUvLk93bEJvdC55YW1sIiwiaCI6ImNmNTA0OWI3MDc5MjgyMDA2NWRiMzhlNzEyN2YzMmVhYjc3MDU5NDQifQ==
parthea added a commit that referenced this issue May 11, 2024
…240430 (#900) (#12648)

- [ ] Regenerate this pull request now.

Source-Link:
googleapis/googleapis@3820562

Source-Link:
googleapis/googleapis-gen@a2cd2c3
Copy-Tag:
eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWNvbXB1dGUvLk93bEJvdC55YW1sIiwiaCI6ImEyY2QyYzNiYWNiZjlhZWNmN2RkMWY4ODQ1MGE2YTE0NTdlMjQzOGEifQ==

BEGIN_NESTED_COMMIT
feat: [google-cloud-compute] Update Compute Engine API to revision
20240421 (#899)
Source-Link:
googleapis/googleapis@55499b5

Source-Link:
googleapis/googleapis-gen@cf5049b
Copy-Tag:
eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWNvbXB1dGUvLk93bEJvdC55YW1sIiwiaCI6ImNmNTA0OWI3MDc5MjgyMDA2NWRiMzhlNzEyN2YzMmVhYjc3MDU5NDQifQ==
END_NESTED_COMMIT
BEGIN_NESTED_COMMIT
feat: [google-cloud-compute] Update Compute Engine API to revision
20240407 (#890)
Source-Link:
googleapis/googleapis@018c0e3

Source-Link:
googleapis/googleapis-gen@dad8476
Copy-Tag:
eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWNvbXB1dGUvLk93bEJvdC55YW1sIiwiaCI6ImRhZDg0NzZjOTRlYjFlY2IyZmQ3MmYyOTY4MjVlOTYyMWVhOGI0NWQifQ==
END_NESTED_COMMIT

---------

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Co-authored-by: Anthonios Partheniou <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: pubsub Issues related to the Pub/Sub API.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants