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

Pub/Sub empty topic batch fails #1955

Closed
tcroiset opened this issue Jul 4, 2016 · 1 comment
Closed

Pub/Sub empty topic batch fails #1955

tcroiset opened this issue Jul 4, 2016 · 1 comment
Assignees
Labels
api: pubsub Issues related to the Pub/Sub API. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@tcroiset
Copy link

tcroiset commented Jul 4, 2016

with topic.batch() as batch:
  for obj in rows:
    batch.publish(b'bla')

fails if rows is empty:

Traceback (most recent call last):

File "/usr/local/lib/python2.7/dist-packages/gcloud/pubsub/topic.py", line 420, in exit
self.commit()
File "/usr/local/lib/python2.7/dist-packages/gcloud/pubsub/topic.py", line 449, in commit
message_ids = api.topic_publish(self.topic.full_name, self.messages[:])
File "/usr/local/lib/python2.7/dist-packages/gcloud/pubsub/connection.py", line 205, in topic_publish
method='POST', path='/%s:publish' % (topic_path,), data=data)
File "/usr/local/lib/python2.7/dist-packages/gcloud/connection.py", line 344, in api_request
error_info=method + ' ' + url)
BadRequest: 400 The value for message_count is too small. You passed 0 in the request, but the minimum value is 1. (POST https://pubsub.googleapis.com/v1/projects/karos-api/topics/api-prod:publish)

@daspecster daspecster added the api: pubsub Issues related to the Pub/Sub API. label Jul 4, 2016
@tseaver
Copy link
Contributor

tseaver commented Jul 4, 2016

Thanks for the report! gcloud.pubsub.topic.Batch.commit should indeed be a no-op if there are no messages accumulated.

@daspecster daspecster added the type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. label Jul 4, 2016
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. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

4 participants