stale-leather-91675
11/14/2022, 3:41 PM/admin/clients
endpoint using hydra 2.0.2
I believe this affects all page_sizes but noticed it with smaller values than the default ones.
When making a GET
query to /admin/clients
with page_size=3
set to the link value returned for the next page is:
</admin/clients?page_size=3&page_token=eyJwYWdlIjoiMyIsInYiOjF9>; rel="next"
and if we decode the page_token
we get {"page":"3","v":1}
. I would expect the page value to be 1 here to get the next page, but instead we get the offset to the next page.
When making new request with the link returned we now get stuff gets weird, we have the following code in
client/handler.go:508
page, itemsPerPage := x.ParsePagination(r)
filters := Filter{
Limit: itemsPerPage,
Offset: page * itemsPerPage,
Name: r.URL.Query().Get("client_name"),
Owner: r.URL.Query().Get("owner"),
}
in this example ParsePagination
returns page=3
and itemsPerPage=3
which is correct based on the input where everything is offset based and not page based. But then we create a offset again with Offset: page * itemsPerPage
which is wrong (using offset to create a new offset) making it impossible to page over the clients.
So we are mixing offset and page based pagination. Which is the way we want to do stuff?
I would probably prefer changing the page_token
content from {"page":"3","v":1}
to {"offset":"3","v":1}
to keep the token stable and independent from the page_size
query param.
I can have a issue regarding the bug.