Skip to content

Fix refs pagination for updated-at sort

Igor Drozdov requested to merge id-fix-page-token-for-committerdate-sort into master

There's buggy behavior:

When refs are sorted by committerdate and page token is passed, then weird results are returned. It works fine when refs are sorted by refname though.

IsPageToken defined in internal/gitaly/service/ref/refs.go is using bytes.Compare which compares refs alphabethically.

It works fine when refs are being sorted by refname, but when we sort by another field, IsPageToken would unexpectedly return the first result that is greater alphabetically.

For example, if refs have been created in the following order: a c b d and we pass { SortBy: 'updated_asc', PageToken: 'b', Limit: 1 }, then we get the ref b, while the expected result is d.

We can use bytes.HasPrefix instead to fix this case

Edited by Igor Drozdov

Merge request reports