GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — PubSub ValueError: Project from client (A) should agree with project from resource(B). · Issue #1827 · googleapis/google-cloud-python

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

New issue
Copy link
New issue
Copy link
Closed
Closed
PubSub ValueError: Project from client (A) should agree with project from resource(B).#1827
Copy link
Assignees
tseaver
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.

Description

@tarzanjw
tarzanjw
opened on May 27, 2016
Issue body actions

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

  1. dhermes
    added
    api: pubsubIssues related to the Pub/Sub API.
    on May 27, 2016
  2. dhermes commented on May 27, 2016

    @dhermes
    dhermes
    on May 27, 2016
    Contributor
    More actions

    @tmatsuo Can you take a peek (sanity check our project "verification")?

  3. tarzanjw commented on May 27, 2016

    @tarzanjw
    tarzanjw
    on May 27, 2016
    Author
    More actions

    On the other hand, this error happens again

      client = pubsub.Client(project='B')
      client.list_subscriptions()  # same error
  4. dhermes commented on May 27, 2016

    @dhermes
    dhermes
    on May 27, 2016
    Contributor
    More actions

    What is the stack trace in that case?

  5. tarzanjw commented on May 27, 2016

    @tarzanjw
    tarzanjw
    on May 27, 2016
    Author
    More actions

    I ran it in python console, I also hide some information about path.

    Do you need something more?

  6. dhermes commented on May 27, 2016

    @dhermes
    dhermes
    on May 27, 2016
    Contributor
    More actions

    I'm curious what's actually triggering the error, so providing a stack trace like you did above is helpful. (I need to reproduce the bug.)

  7. tarzanjw commented on May 27, 2016

    @tarzanjw
    tarzanjw
    on May 27, 2016
    Author
    More actions

    This is the full log

    Python log

    Python 3.5.1 (default, Jan 22 2016, 08:54:32) 
    [GCC 4.2.1 Compatible Apple LLVM 7.0.2 (clang-700.1.81)] on darwin
    >>> from gcloud import pubsub
    >>> client = pubsub.Client(project='vnpapis')
    >>> topic = client.topic('binlog2-vatgia-orders-insert')
    >>> topic.list_subscriptions()
    Traceback (most recent call last):
      File "<input>", line 1, in <module>
      File "/Users/tarzan/sources/vnpapis/vnpapi-etl/lib/python3.5/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 "/Users/tarzan/sources/vnpapis/vnpapi-etl/lib/python3.5/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 "/Users/tarzan/sources/vnpapis/vnpapi-etl/lib/python3.5/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 (vnpapis) should agree with project from resource(vatgia-voicecall).

    Graph API log

    GET https://pubsub.googleapis.com/v1/projects/vatgia-voicecall/subscriptions?key={YOUR_API_KEY}
    
    {
     "subscriptions": [
      {
       "name": "projects/vatgia-voicecall/subscriptions/binlog2-vatgia-voicecall-on-order-insert",
       "topic": "projects/vnpapis/topics/binlog2-vatgia-orders-insert",
       "pushConfig": {
        "pushEndpoint": "https://vatgia-voicecall.appspot.com/on_order_change"
       },
       "ackDeadlineSeconds": 10
      }
     ]
    }
    
  8. tseaver commented on May 27, 2016

    @tseaver
    tseaver
    on May 27, 2016
    Contributor
    More actions

    FWIW, the reason we are verifying the project is because the subscription uses the client (which binds a single project) to perform API requests. If we want to support this usecase, we will have to detect the mismatch and somehow fabricate a new client on the fly for the "foreign" subscription.

  9. daspecster commented on May 27, 2016

    @daspecster
    daspecster
    on May 27, 2016
    Contributor
    More actions

    @tseaver @dhermes
    GET https://pubsub.googleapis.com/v1/{project=projects/*}/subscriptions
    https://cloud.google.com/pubsub/reference/rest/v1/projects.subscriptions/list

    Would it make sense to allow the project to be passed to list_subscriptions(project='A')?

    or maybe more intuitively, could topic.list_subscriptions() just return the subscriptions but have Subscription._project be the actual project ID instead of self._client.project? Would require some refactoring though.

  10. tseaver commented on May 27, 2016

    @tseaver
    tseaver
    on May 27, 2016
    Contributor
    More actions

    As I said, Subscription instances don't make API calls directly: they currently use their client instance bound to their topic. In the OP's case, that client instance has a different project ID than the subscription.

    To make the "foreign subscription" case work, we would need to do the following:

    • Have Subscription instances hold direct references to their client.
    • When listing subscriptions for a topic (as opposed to for the client/project), be able to construct new Client instance(s) for those from foreign projects.
  11. daspecster commented on May 27, 2016

    @daspecster
    daspecster
    on May 27, 2016
    Contributor
    More actions

    @tseaver, couldn't the Subscriptions() track which project they're associated with? Maybe by having both the Subscription.project and Subscription._client.project. That could require more factoring of pubsub than I'm thinking though.

    I think I see what you mean though, thanks for the clarification!

  12. tseaver
    added
    type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.
    on Aug 25, 2016
  13. tseaver
    self-assigned this
    on Aug 25, 2016
  14. daspecster commented on Dec 13, 2016

    @daspecster
    daspecster
    on Dec 13, 2016
    Contributor
    More actions

    Possibly related Stackoverflow question.

    http://stackoverflow.com/questions/41029292/how-can-i-create-a-pubsub-subscription-for-a-topic-in-a-different-google-cloud-p

  15. lukesneeringer
    added
    priority: p2Moderately-important priority. Fix may not be included in next release.
    on Apr 19, 2017
  16. lukesneeringer commented on Aug 8, 2017

    @lukesneeringer
    lukesneeringer
    on Aug 8, 2017
    Contributor
    More actions

    Hello! :-)
    First, a mea culpa; I have not done as good of a job at keeping up with issues as I should have. If you are getting this (I admit it) cut and paste, it is likely because your issue sat for too long.

    In this case, I have been in the process of making a radical update to the PubSub library (#3637) to add significant performance improvements and a new surface, which we hope to launch soon. As such, I am clearing out issues on the old library. It is my sincere goal to do a better job of being on top of issues in the future.

    As the preceding paragraph implies, I am closing this issue. If the revamped library does not solve your issue, however, please feel free to reopen.

    Thanks!

  17. lukesneeringer
    closed this as completedon Aug 8, 2017
  18. parthea
    added a commit that references this issue on Sep 22, 2023

    chore: move samples from python-docs-sample (#66)

    d3dcbbc
  19. parthea
    added a commit that references this issue on Nov 24, 2025

    chore(deps): update dependency urllib3 to v2.0.7 [security] (#1827)

    4b18f02
  20. parthea
    added a commit that references this issue on Mar 6, 2026

    feat: support RANGE query parameters (#1827)

    0350eec
  21. parthea
    added a commit that references this issue on Apr 1, 2026

    feat: add describe() method to Series (#1827)

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

Metadata

Metadata

Assignees

  • @tseaver
    tseaver

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

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.