Skip to content

Repository tree keyset pagination headers come back with "name" instead of "id"

Summary

Originally reported via this internal ticket

When using keyset pagination for /api/v4/projects/:project/repository/tree the link header in the response incorrectly uses a the object name instead of the ID, which makes the header not work when consumed.

Steps to reproduce

  • Enable feature flag via Feature.enable(:repository_tree_gitaly_pagination)
  • In a project with multiple files in a directory perform request such as GET <instance>/api/v4/projects/5/repository/tree?pagination=keyset&per_page=100&path=a

Example Project

What is the current bug behavior?

link header comes back with: < <INSTANCE>/api/v4/projects/5/repository/tree?id=5&page=1&page_token=<FILE_NAME>&pagination=keyset&path=a&per_page=100&recursive=false>; rel="next"

What is the expected correct behavior?

link header should come back with: < <INSTANCE>/api/v4/projects/5/repository/tree?id=5&page=1&page_token=<OBJECT_ID>&pagination=keyset&path=a&per_page=100&recursive=false>; rel="next"

Relevant logs and/or screenshots

Output of checks

Results of GitLab environment info

Expand for output related to GitLab environment info

(For installations with omnibus-gitlab package run and paste the output of:
`sudo gitlab-rake gitlab:env:info`)

(For installations from source run and paste the output of:
`sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production`)

Results of GitLab application Check

No errors, tested on 15.4.2 and 15.2.4 and behavior is consistent across those

 Ruby:         ruby 2.7.5p203 (2021-11-24 revision f69aeb8314) [x86_64-linux]
 GitLab:       15.4.2-ee (4eacd5378ab) EE
 GitLab Shell: 14.10.0
 PostgreSQL:   13.6
 Geo enabled:  yes
 Geo server:   primary
Expand for output related to the GitLab application check

(For installations with omnibus-gitlab package run and paste the output of: sudo gitlab-rake gitlab:check SANITIZE=true)

(For installations from source run and paste the output of: sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production SANITIZE=true)

(we will only investigate if the tests are passing)

Possible fixes

Not sure about this one, will do some more research tomorrow and come back to this.

Edited by Ulises Fierro