Skip to content

PubSub ValueError: Project from client (A) should agree with project from resource(B). #1827

Closed
@tarzanjw

Description

@tarzanjw

Say that I have 2 projects, A and B.

From project A, I have topics: projects/A/topics/events.
From project B, I add a subscription to above topic, subscription name is: projects/B/subscriptions/on-A-events.

Note: I created the subscription via Graph API Explorer, not via the Cloud Console (just can't do it with Cloud Console)

So, these code will raise an Exception:

  from gcloud import pubsub

  c = pubsub.Client(project='A')
  t = c.topic('events')
  subs = t.list_subscriptions()  # Error
  Traceback (most recent call last):
    File "<input>", line 1, in <module>
    File "<input>", line 1, in <listcomp>
    File ".../site-packages/gcloud-0.14.0-py3.5.egg/gcloud/pubsub/topic.py", line 311, in list_subscriptions
      sub_name = subscription_name_from_path(sub_path, self.project)
    File "../site-packages/gcloud-0.14.0-py3.5.egg/gcloud/pubsub/_helpers.py", line 73, in subscription_name_from_path
      return _name_from_project_path(path, project, _SUBSCRIPTION_TEMPLATE)
    File ".../site-packages/gcloud-0.14.0-py3.5.egg/gcloud/_helpers.py", line 464, in _name_from_project_path
      'project from resource(%s).' % (project, found_project))
  ValueError: Project from client (A) should agree with project from resource(B).

I take a dive into the source codes, and I see that you guys are assuming that every subscriptions that returned have to be in same project with the client, but it's not in my case.

Is it a bug or my misunderstanding?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions