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 — Handle subscription list for specific topic separately. by andrazhribernik · Pull Request #1411 · googleapis/google-cloud-python

Conversation

@andrazhribernik

@andrazhribernik andrazhribernik commented Jan 21, 2016

Copy link
Copy Markdown

No description provided.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@googlebot

googlebot commented Jan 21, 2016

Copy link
Copy Markdown

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed, please reply here (e.g. I signed it!) and we'll verify. Thanks.


  • If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check your existing CLA data and verify that your email is set on your git commits.
  • If you signed the CLA as a corporation, please let us know the company's name.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@googlebot googlebot added the cla: no This human has *not* signed the Contributor License Agreement. label Jan 21, 2016
@andrazhribernik

andrazhribernik commented Jan 21, 2016

Copy link
Copy Markdown
Author

Cytora signed it!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@andrazhribernik
Handle subscription list for specific topic separately.
3dc9cc0
Update code
@andrazhribernik
andrazhribernik force-pushed the bug-fix-pubsub-list-subscriptions branch from c3030ba to 3dc9cc0 Compare January 21, 2016 10:20
@peterhudec
Merge pull request #1 from cytora/bug-fix-pubsub-list-subscriptions
856a09e
Handle subscription list for specific topic separately.
@jgeewax

jgeewax commented Jan 21, 2016

Copy link
Copy Markdown
Contributor

Thanks for the PR!

Not sure I understand what's happening here. Can you share a bit more about what you're trying to do? And maybe add some tests?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@andrazhribernik

andrazhribernik commented Jan 21, 2016

Copy link
Copy Markdown
Author

Sorry for not adding any description and tests. It is basically a bug fix.

When we tried to use this functionality:

from gcloud import pubsub
client = pubsub.Client(project=<project_name>)
client.list_subscriptions(topic_name=<topic_name>)

we got the following error.

TypeError                                 Traceback (most recent call last)
<ipython-input-3-8be845bada22> in <module>()
----> 1 client.list_subscriptions(topic_name="test_aw_2")

/Users/andrazhribernik/cytora/gcloud-python/gcloud/pubsub/client.py in list_subscriptions(self, page_size, page_token, topic_name)
    129         subscriptions = [Subscription.from_api_repr(resource, self,
    130                                                     topics=topics)
--> 131                          for resource in resp['subscriptions']]
    132         return subscriptions, resp.get('nextPageToken')
    133 

/Users/andrazhribernik/cytora/gcloud-python/gcloud/pubsub/subscription.pyc in from_api_repr(cls, resource, client, topics)
     66         if topics is None:
     67             topics = {}
---> 68         topic_path = resource['topic']
     69         topic = topics.get(topic_path)
     70         if topic is None:

TypeError: string indices must be integers

It also fails with different error if param topic_name is not specified

from gcloud import pubsub
client = pubsub.Client(project=<project_name>)
client.list_subscriptions()

returns

ValueError                                Traceback (most recent call last)
<ipython-input-4-39df795327d3> in <module>()
----> 1 client.list_subscriptions()

/Users/andrazhribernik/cytora/gcloud-python/gcloud/pubsub/client.py in list_subscriptions(self, page_size, page_token, topic_name)
    129         subscriptions = [Subscription.from_api_repr(resource, self,
    130                                                     topics=topics)
--> 131                          for resource in resp['subscriptions']]
    132         return subscriptions, resp.get('nextPageToken')
    133 

/Users/andrazhribernik/cytora/gcloud-python/gcloud/pubsub/subscription.pyc in from_api_repr(cls, resource, client, topics)
     71             # NOTE: This duplicates behavior from Topic.from_api_repr to avoid
     72             #       an import cycle.
---> 73             topic_name = topic_name_from_path(topic_path, client.project)
     74             topic = topics[topic_path] = client.topic(topic_name)
     75         _, _, _, name = resource['name'].split('/')

/Users/andrazhribernik/cytora/gcloud-python/gcloud/pubsub/_helpers.pyc in topic_name_from_path(path, project)
     36     if (len(path_parts) != 4 or path_parts[0] != 'projects' or
     37             path_parts[2] != 'topics'):
---> 38         raise ValueError('Expected path to be of the form '
     39                          'projects/{project}/topics/{topic_name}')
     40     if (len(path_parts) != 4 or path_parts[0] != 'projects' or

ValueError: Expected path to be of the form projects/{project}/topics/{topic_name}

The code we implemented basically solve a problem with inconsistency of GCloud REST API. It worked for us and was very quick fix. If you think this should be solved in a different way, I would be happy to hear your ideas.

I just took a look on tests now and it seems that tests do not reflect the output from GCloud REST API.

GCloud REST API response for a specific topic does not return a list of format [{'name': SUB_PATH, 'topic': TOPIC_PATH}], but returns list of strings (['topic1 name', 'topic2 name', ...]). It also seems pagination is on by default, which is not reflected in tests.

I am wondering. Is there a bug on GCLOUD REST API or on the gcloud-python side. If you think that this needs to be fix, I can refactor tests as well.

I hope it is clearer now. If you need any more informations, please do not hesitate to ask me.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@andrazhribernik
Upgrade version in setup.py
08064bc
@andrazhribernik
andrazhribernik force-pushed the bug-fix-pubsub-list-subscriptions branch from 6e7b4d3 to 08064bc Compare January 21, 2016 14:15
@jgeewax

jgeewax commented Jan 21, 2016

Copy link
Copy Markdown
Contributor

/cc @tseaver : This seems like a legit concern. Curious why our system tests don't catch this?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

tseaver
tseaver reviewed Jan 28, 2016
View reviewed changes
Comment thread setup.py Outdated

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@tseaver

tseaver commented Jan 28, 2016

Copy link
Copy Markdown
Contributor

@andrazhribernik can you supply the value of resource when the tracebacks are raised? I'm having a hard time following the logic for your changes.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@andrazhribernik

andrazhribernik commented Jan 31, 2016

Copy link
Copy Markdown
Author

@tseaver Value of resource is different whether param 'topic_name' is specified or not.

  1. topic_name is not specified
from gcloud import pubsub
client = pubsub.Client(project=<project_name>)
client.list_subscriptions()

Error is raised, if there is any subscription for a topic that has already been deleted (_deleted-topic_).
Sample value of resp object:

{u'subscriptions': [
     {
        u'topic': u'projects/<project_id>/topics/<topic_name>',
        u'ackDeadlineSeconds': 10,
        u'pushConfig': {},
        u'name': u'projects//<project_id>/subscriptions//<subscription_name>''
    },
    {
        u'topic': u'_deleted-topic_',
        u'ackDeadlineSeconds': 10,
        u'pushConfig': {},
        u'name': u'projects/<project_id>/subscriptions/<subscription_name>'
    },
  1. topic_name is specified
from gcloud import pubsub
client = pubsub.Client(project=<project_name>)
client.list_subscriptions(topic_name=<topic_name>)

Error is raised for every request of this type.
Sample value of resp object:

{u'subscriptions': [
        u'projects/<project_id>/subscriptions/<subscription_name1>',
        u'projects/<project_id>/subscriptions/<subscription_name2>'
    ]
}

I hope this explanation will help to understand my code updates.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@googlebot

googlebot commented Jan 31, 2016

Copy link
Copy Markdown

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for the commit author(s). If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@andrazhribernik
Downgrade version.
4d016a4
@tseaver

tseaver commented Feb 15, 2016

Copy link
Copy Markdown
Contributor

@andrazhribernik I believe that #1440 should address this issue. @jgeewax, it also adds a system test for list_subscriptions (adding one for the list_topics case is too hard, as there is no guarantee that a given project will have no topics at all).

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@tseaver tseaver closed this Feb 15, 2016
parthea pushed a commit that referenced this pull request Nov 24, 2025
@vchudnov-g
feat: Add BUILD rule parameter to allow setting numeric enums (#1411)
eec5d5e
This allows generator users to set the numeric-enum-response parameter at generation time via the BUILD rule. The default is `False` for backward compatibility.
parthea pushed a commit that referenced this pull request Nov 26, 2025
@BigTailWolf
chore: update token (#1411)
1988a60
parthea pushed a commit that referenced this pull request Mar 2, 2026
@gcf-owl-bot @abbrowne126
feat: Add SchemaViolationReason to IngestionFailureEvent (#1411)
8661b30
Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Co-authored-by: Andrew Browne <[email protected]>
parthea pushed a commit that referenced this pull request Mar 9, 2026
@cojenco
fix: filter download_kwargs in BlobReader (#1411)
6d2e2ca
parthea pushed a commit that referenced this pull request Mar 9, 2026
@sinhasubham
feat(spanner): add lazy decode to partitioned query (#1411)
5939027
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

cla: no This human has *not* signed the Contributor License Agreement.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@andrazhribernik @googlebot @jgeewax @tseaver @peterhudec
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.