-
Notifications
You must be signed in to change notification settings - Fork 5
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
Pagination is broken when requesting non-existent page number #15
Comments
Possible this comment describes the reason for this issue:
|
The issue here is that ES throws an error and we move on to DynamoDB which does not support pagination and thus returns all data. Let's check if the error is due to the number of pages exceeding what ES can support and if yes, we simply return with empty array. Otherwise, for any other error, let us proceed as we do currently - to fetch ALL records from dynamodb |
Assigned to @meshde |
ES does not return any error in this case. It simply returns an object of the form: {
"total": 3,
"perPage": 1,
"page": 999,
"results": []
} Since As shown in the sample return object above, the code has access to pagination related data at this point. This can be used to calculate whether the empty result is due to a non-existent page (as compared to data in ES being out of sync) and the empty result can be returned then and there, without having to fetch data from Dynamo. @callmekatootie Please confirm whether this condition check is to be added or the logic is to be left as it is. |
@maxceem This is now resolved in |
@callmekatootie looks like there are still some issues. I'm trying to retrieve page
|
This error is intentional - you tried to fetch more than the allowed number of records - it is a bad request (http status code 400). Try this instead - https://api.topcoder-dev.com/v5/lookups/devices?page=499 - it is under the limit of 10,000 records and you will get an empty array. I imagine that you will get an empty array much earlier (as in, with a lesser value for |
Hmm, I was trying to request page Also, request https://api.topcoder-dev.com/v5/lookups/devices?page=999 suppose to return |
Great, I think this should be enough for real-world usage. |
So request with query param Let me know if that did not make sense. |
Thanks, @callmekatootie it makes sense. |
If we request a page for devices which doesn't exist, the API returns all the data and doesn't return pagination headers:
https://api.topcoder-dev.com/v5/lookups/devices?page=9999
I guess the expected response should be no data, as we request a page that doesn't have any records.
The text was updated successfully, but these errors were encountered: