Commits API per_page behavior is inconsistent
Summary
It is possible to submit Commits API requests with per_page parameters beyond the documented maximum. They will succeed if per_page is strictly smaller than the total number of possibly returned items as listed by the X-Total header in the response.
Steps to reproduce
Public GET Api calls to:
https://www.gitlab.com/api/v4/projects/gitlab-org%2Fgitlab/repository/commits?ref_name=32d6426b86ca1ce76b9818ac1428712a3cf8ff8d..a604fffd4ba717f879f2be7f3e6645b85d87220c
with various per_page settings: Note that X-Total header in response is 263, so there are 263 commits between these two refs.
No per_page: 20 commits returned
per_page = 100: 100 commits returned
per_page = 200: 200 commits returned (note that this is larger than the documented maximum per_page size of 100)
per_page = 263: 100 commits returned
per_page = 262: 262 commits returned
Example Project
This behavior is exhibited on the current gitlab.com server.
What is the current bug behavior?
per_page values above the documented maximum (100) are permitted. However if the specified per_page value is larger than the actual TOTAL number of items in the query (as specified by the X-Total header in the response), the response will only contain 100 items.
What is the expected correct behavior?
Specifying a per_page above the documented maximum should return an error response. Alternately, the practical functional maximum per_page should not depend on the number of total items.
Relevant logs and/or screenshots
I wrote a very quick set of python commands to demonstrate the problem.
import requests
gl_url = "https://www.gitlab.com/api/v4/projects/gitlab-org%2Fgitlab/repository/commits?ref_name=32d6426b86ca1ce76b9818ac1428712a3cf8ff8d..a604fffd4ba717f879f2be7f3e6645b85d87220c"
requests.get(gl_url).headers['X-Total']
'263'
len(requests.get(gl_url).json())
20
len(requests.get(gl_url, params={'per_page': 200}).json())
200
len(requests.get(gl_url, params={'per_page': 263}).json())
100
len(requests.get(gl_url, params={'per_page': 262}).json())
262
Output of checks
This bug happens on GitLab.com