Pagination not working on new vulnerabilities API
Summary
The pagination headers are not being created/sent on the new vulnerabilities API.
Steps to reproduce
- Pull down branch
6709-group-security-dashboard-api-integration-fe-ee
and run the project with the GDK. - Edit this line and change
10.times do
to50.times do
(or any number greater than 20) - Go into the rails console
bundle exec rails console
- Seed the dummy vulnerabilities
load 'db/fixtures/development/20_vulnerabilities.rb'
- Go to the local instance of gitlab and create a group if you don't already have one
- Go to
http://localhost:3001/groups/[your group name]/-/security/dashboard
- Open up the network tab and look for a request made to
http://localhost:3001/groups/open-source/-/security/vulnerabilities
- Inspect the response headers
Example Project
Whilst in the previous section I recommended checking out branch 6709-group-security-dashboard-api-integration-fe-ee
. The bug is in master, but checking out that branch and running the project makes the issue a little easier to see.
What is the current bug behavior?
There are no headers relevant to pagination and so the pagination on the Frontend doesn't render.
What is the expected correct behavior?
The pagination should render and you should see the following headers on the request response:
X-Next-Page: 3
X-Page: 2
X-Per-Page: 10
X-Prev-Page: 1
X-Total: 50
X-Total-Pages: 5
Possible fixes
It seems the culprit here is the to_a
method on this line. It seems to strip all knowledge of anything but the first 10 results before passing it to the pagination method.
Removing that line fixes the problem and brings the pagination back, but we end out seeing 20 results per page rather than the desired 10.