Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Iterating through repo.get_tags() throws NoneType TypeError for repositories with lots of tags #278

Closed
erichaase opened this issue Oct 6, 2014 · 5 comments
Assignees
Labels

Comments

@erichaase
Copy link

For repositories with lots of tags (git, linux, etc.), iterating through repo.get_tags() throws a NoneType TypeError. Please see the following for the steps to recreate:

eric@white:~/autoport> pip freeze|ack pygithub
PyGithub==1.25.0

eric@white:~/autoport> python
Python 2.7.3 (default, Feb 27 2014, 20:00:17) 
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from github import Github
>>> tags = Github("...").get_repo(2325298).get_tags()
>>> for tag in tags:
...     print tag
... 
<github.Tag.Tag object at 0xb6e1848c>
<github.Tag.Tag object at 0xb6e18e8c>
...
<github.Tag.Tag object at 0xb6d14b0c>
<github.Tag.Tag object at 0xb6d14c0c>
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/github/PaginatedList.py", line 48, in __iter__
    newElements = self._grow()
  File "/usr/local/lib/python2.7/dist-packages/github/PaginatedList.py", line 60, in _grow
    newElements = self._fetchNextPage()
  File "/usr/local/lib/python2.7/dist-packages/github/PaginatedList.py", line 177, in _fetchNextPage
    for element in data
  File "/usr/local/lib/python2.7/dist-packages/github/GithubObject.py", line 74, in __init__
    self._storeAndUseAttributes(headers, attributes)
  File "/usr/local/lib/python2.7/dist-packages/github/GithubObject.py", line 86, in _storeAndUseAttributes
    self._useAttributes(attributes)
  File "/usr/local/lib/python2.7/dist-packages/github/Tag.py", line 73, in _useAttributes
    if "commit" in attributes:  # pragma no branch
TypeError: argument of type 'NoneType' is not iterable
@jacquev6
Copy link
Member

jacquev6 commented Oct 6, 2014

Wow thanks for reporting that! I'll have a look in the coming days.

@jacquev6 jacquev6 self-assigned this Oct 6, 2014
@jacquev6
Copy link
Member

jacquev6 commented Oct 8, 2014

The issue comes from the GitHub API (see the nulls at the end):

curl https://api.github.com/repositories/2325298/tags?page=13

[
  {
    "name": "v2.6.15-rc7",
    "zipball_url": "https://api.github.com/repos/torvalds/linux/zipball/v2.6.15-rc7",
    "tarball_url": "https://api.github.com/repos/torvalds/linux/tarball/v2.6.15-rc7",
    "commit": {
      "sha": "f89f5948fc10bb973cd452d2e334da207828e228",
      "url": "https://api.github.com/repos/torvalds/linux/commits/f89f5948fc10bb973cd452d2e334da207828e228"
    }
  },
  {...........},
  {
    "name": "v2.6.12",
    "zipball_url": "https://api.github.com/repos/torvalds/linux/zipball/v2.6.12",
    "tarball_url": "https://api.github.com/repos/torvalds/linux/tarball/v2.6.12",
    "commit": {
      "sha": "9ee1c939d1cb936b1f98e8d81aeffab57bae46ab",
      "url": "https://api.github.com/repos/torvalds/linux/commits/9ee1c939d1cb936b1f98e8d81aeffab57bae46ab"
    }
  },
  null,
  null
]

I'll contact GitHub to see if they can fix it on their side. I'll also make a workaround in PyGithub.

@jacquev6
Copy link
Member

jacquev6 commented Oct 8, 2014

Work-around in aadc286 and https://pypi.python.org/pypi/PyGithub/1.25.2

Thanks for reporting!

@jacquev6 jacquev6 closed this as completed Oct 8, 2014
@jacquev6
Copy link
Member

jacquev6 commented Oct 8, 2014

Response from Ivan Žužak (GitHub Support):

The team deployed some changes which should have resolved this issue. Let us know if you're still seeing null items in some responses, though.
Thanks again!

@erichaase
Copy link
Author

Great, thanks for the quick turnaround on this!

mattpep added a commit to ministryofjustice/PyGithub that referenced this issue Sep 25, 2015
I suspect this is related to the cause of
PyGithub#278 (comment) in
that the response from the github API contains null for some elements.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants