Skip to content

Pub/Sub empty topic batch fails #1955

Closed

Description

@tcroiset
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)

Activity

  1. added
    api: pubsub
    on Jul 4, 2016
  2. tseaver commented on Jul 4, 2016

    @tseaver
    Contributor

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

  3. added
    type: bug
    on Jul 4, 2016
  4. added a commit that references this issue on Jul 4, 2016
    88243b0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

api: pubsubtype: bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions