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

Org Repository Pagination Only Returns First Page #2963

Open
squatched opened this issue Apr 30, 2024 · 2 comments
Open

Org Repository Pagination Only Returns First Page #2963

squatched opened this issue Apr 30, 2024 · 2 comments

Comments

@squatched
Copy link
Contributor

squatched commented Apr 30, 2024

My org has hundreds of repositories, but when I call Github().get_organization(org_slug).get_repos(sort="full_name", type="all"), the resulting object only ever has at most 50 objects in it (repos.totalCount is 50 as well as the size of the resulting get_page(0)) and when I try and get any page other than 1, I get an empty list returned.

I would expect this to work:

repos = github.Github().get_organization("my_org").get_repos(sort="full_name", type="all")

assert repos.totalCount > 50
assert len(repos.get_page(1)) != 0
@hodeinavarro
Copy link

As of today with v2.3.0

Python 3.12.3 (main, Apr  9 2024, 08:09:14) [Clang 15.0.0 (clang-1500.3.9.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> from github import Github
>>> github = Github(os.getenv('GITHUB_TOKEN'))
>>> repos = github.get_organization('microsoft').get_repos(sort='full_name', type='all')
>>> assert repos.totalCount > 50
>>> assert len(repos.get_page(1)) != 0
>>> repos.totalCount
6212
>>> len(repos.get_page(1))
30

I'm thinking it could be about the token permissions and repository visibility as mentioned in the docs

The token must have the following permission set:

  • metadata:read

This endpoint can be used without authentication or the aforementioned permissions if only public resources are requested.

Maybe your token could list 50 public repos, but not the others? Seems too much of a coincidence, but just trying to throw some light

@hodeinavarro
Copy link

I just noticed that you don't use a token in your example, which I assumed you'd since you do not provide organization name, but I get the same result without a token.

Python 3.12.3 (main, Apr  9 2024, 08:09:14) [Clang 15.0.0 (clang-1500.3.9.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from github import Github
>>> github = Github()
>>> repos = github.get_organization('microsoft').get_repos(sort='full_name', type='all')
>>> assert repos.totalCount > 50
>>> assert len(repos.get_page(1)) != 0
>>> repos.totalCount
6212
>>> len(repos.get_page(1))
30

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants