-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Broken pagination using page_token
in Ory Hydra APIs
#3362
Comments
Thank you for the report! Adding this to our backlog. |
page_token
in Ory Hydra APIs
ps: contributions also welcomed, we will probably not be able to work on this in the next weeks |
I'm happy to help with this issue, would you prefer storing the offset or a page index in the |
The page index would be nicer to store in the page_token! but offset is also fine - whatever is easier :) |
I would say you can't do it. |
Preflight checklist
Describe the bug
When paginating over the oauth2 clients using the
/admin/clients
endpoint the the result returned jumps over multiple clients.Reproducing the bug
Make a request to
/admin/clients?page_size=3
The expected result is to have 3 clients returned and a link header containing
</admin/clients?page_size=3&page_token=eyJwYWdlIjoiMyIsInYiOjF9>; rel="next"
Make a request using the next Link returned int the header
/admin/clients?page_size=3&page_token=eyJwYWdlIjoiMyIsInYiOjF9
Here we expect to get the following 3 clients. But instead it jumps multiple clients.
You can spot this by comparing the result from a request to
/admin/clients?page_size=300
Relevant log output
No response
Relevant configuration
Version
2.0.2
On which operating system are you observing this issue?
macOS
In which environment are you deploying?
Docker
Additional Context
If we take a deeper look into the token returned from the
/admin/clients?page_size=3
request we see that it contains:{"page":"3","v":1}
.If it was the page return we should expect to get the value 1 and not 3, it instead looks like we are getting a offset to the next page.
But If we look when parsing the token in the request using the token we see the following:
hydra/client/handler.go
Lines 507 to 514 in c65342e
Here we still handle it as a page and not a offset getting the values
page=3
anditemsPerPage=3
ParsePagination
and then calculating a offsetOffset: page * itemsPerPag
ending up as9
. This means we are jumping over the clients with index 3-9 when paging.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 independent from thepage_size
query param.The text was updated successfully, but these errors were encountered: