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

Pagination starts on page 0 #377

Closed
zhelanov opened this issue Nov 17, 2017 · 3 comments
Closed

Pagination starts on page 0 #377

zhelanov opened this issue Nov 17, 2017 · 3 comments

Comments

@zhelanov
Copy link

According to documentation,

The first page is page 1, not page 0.

but when I try to get the 'first' page for commits list then I need to request page 0:
project.commits.list(page=0, per_page=10000)

@gpocentek
Copy link
Contributor

@zhelanov If I use page=0 there are no commits returned:

In [13]: p.commits.list(ref='master', page=0, per_page=1)
Out[13]: []

In [14]: p.commits.list(ref='master', page=1, per_page=1)
Out[14]: [<ProjectCommit id:dc699b9e64b4becbb4f067b69fe97f5fe8df14e7>]

Or for some resources, page 0 and page 1 return the same information:

In [16]: gl.projects.list(page=0, per_page=2)
Out[16]: [<Project id:559>, <Project id:558>]

In [17]: gl.projects.list(page=1, per_page=2)
Out[17]: [<Project id:559>, <Project id:558>]

In [18]: gl.projects.list(page=2, per_page=2)
Out[18]: [<Project id:557>, <Project id:556>]

So if you start looping with page 0 you will end up with duplicated data.

@zhelanov
Copy link
Author

@gpocentek in my case page=0 contains list of commits that is different from page=1.
I use python-gitlab with GitLab API v3

@gpocentek
Copy link
Contributor

From what I see in the v3 to v4 documentation (https://docs.gitlab.com/ce/api/v3_to_v4.html), project commits in v3 was the only API endpoint with pagination starting at 0. I'll update the doc to add a warning.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 9, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants