Skip to content

PubSub: Quickstart examples for Pub/Sub subscriber not working #4394

@Edo-A

Description

@Edo-A

Subscription quickstart documentation for Pub/Sub library is not correct in a couple of points.

  1. The final subscription here should be subscription_name.

    subscription = subscriber.create_subscription(topic, subscription)

    Using it as is throws the following error: NameError: name 'subscription' is not defined

  2. After modifying the line from 1 above to

    subscription = subscriber.create_subscription(topic, subscription_name)

    it throws another error:

    Traceback (most recent call last):
      File "receive.py", line 19, in <module>
        subscription = subscriber.create_subscription(topic, subscription_name)
      File "/path-to-file/pubsub/env/local/lib/python2.7/site-packages/google/cloud/pubsub_v1/_gapic.py", line 42, in <lambda>
        fx = lambda self, *a, **kw: wrapped_fx(self.api, *a, **kw)
      File "/path-to-file/pubsub/env/local/lib/python2.7/site-packages/google/cloud/gapic/pubsub/v1/subscriber_client.py", line 445, in create_subscription
        return self._create_subscription(request, options)
      File "/path-to-file/pubsub/env/local/lib/python2.7/site-packages/google/gax/api_callable.py", line 452, in inner
        return api_caller(api_call, this_settings, request)
      File "/path-to-file/pubsub/env/local/lib/python2.7/site-packages/google/gax/api_callable.py", line 438, in base_caller
        return api_call(*args)
      File "/path-to-file/pubsub/env/local/lib/python2.7/site-packages/google/gax/api_callable.py", line 376, in inner
        return a_func(*args, **kwargs)
      File "/path-to-file/pubsub/env/local/lib/python2.7/site-packages/google/gax/retry.py", line 127, in inner
        ' classified as transient', exception)
    google.gax.errors.RetryError: RetryError(Exception occurred in retry method that was not classified as transient, caused by <_Rendezvous of RPC that terminated with (StatusCode.INVALID_ARGUMENT, Invalid resource name given (name=projects/PROJECTID/topics/TOPICNAME). Refer to https://cloud.google.com/pubsub/overview#names for more information.)>)

    Note that I've copied/pasted the code example and edited the projectID, topic name and subscription name to be valid for my project. Also note that using the example from readthedocs.io (which is the same) generates the exact same error

Metadata

Metadata

Assignees

Labels

api: pubsubIssues related to the Pub/Sub API.priority: p2Moderately-important priority. Fix may not be included in next release.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions