You need to sign in or sign up before continuing.
Keyset pagination using incorrect "Links" header.
Summary
Results of an offset-based pagination request contain a link: ... header that appears to be defined using the RFC 5988 - Web Linking specification.
However, the results of a keyset-based pagination request contain a links: ... header. This seems to be something non-standard, and also makes switching to keyset-based pagination more difficult.
Steps to reproduce
- Request a keyset-based pagination result from the API. For example:
$ curl --header 'PRIVATE-TOKEN: <my private token>' 'https://gitlab.com/api/v4/projects?order_by=id&simple=true&membership=true&archived=false&pagination=keyset&per_page=100'
Example Project
Not applicable since the only keyset-based pagination available as of writing this is the system-wide projects endpoint with order_by=id.
What is the current bug behavior?
The result header contains a links: ... entry.
What is the expected correct behavior?
The result header contains a link: ... entry.
Relevant logs and/or screenshots
Keyset-based pagination:
$ curl -s --dump-header keyset.header --header 'PRIVATE-TOKEN: <my private token>' 'https://gitlab.com/api/v4/projects?order_by=id&simple=true&membership=true&archived=false&pagination=keyset&per_page=100' > /dev/null
$ grep link keyset.header
links: <https://gitlab.com/api/v4/projects?archived=false&id_before=18306059&membership=true&order_by=id&owned=false&page=1&pagination=keyset&per_page=100&repository_checksum_failed=false&simple=true&sort=desc&starred=false&statistics=false&wiki_checksum_failed=false&with_custom_attributes=false&with_issues_enabled=false&with_merge_requests_enabled=false>; rel="next"
Offeset-based pagination:
$ curl -s --dump-header offset.header --header 'PRIVATE-TOKEN: <my private token>' 'https://gitlab.com/api/v4/projects?order_by=id&simple=true&membership=true&archived=false&per_page=100' > /dev/null
$ grep link offset.header
link: <https://gitlab.com/api/v4/projects?archived=false&membership=true&order_by=id&owned=false&page=2&per_page=100&repository_checksum_failed=false&simple=true&sort=desc&starred=false&statistics=false&wiki_checksum_failed=false&with_custom_attributes=false&with_issues_enabled=false&with_merge_requests_enabled=false>; rel="next", <https://gitlab.com/api/v4/projects?archived=false&membership=true&order_by=id&owned=false&page=1&per_page=100&repository_checksum_failed=false&simple=true&sort=desc&starred=false&statistics=false&wiki_checksum_failed=false&with_custom_attributes=false&with_issues_enabled=false&with_merge_requests_enabled=false>; rel="first", <https://gitlab.com/api/v4/projects?archived=false&membership=true&order_by=id&owned=false&page=12&per_page=100&repository_checksum_failed=false&simple=true&sort=desc&starred=false&statistics=false&wiki_checksum_failed=false&with_custom_attributes=false&with_issues_enabled=false&with_merge_requests_enabled=false>; rel="last"
Output of checks
This bug happens on GitLab.com
Possible fixes
Change to use a link: ... header before it's too late.