-
Notifications
You must be signed in to change notification settings - Fork 105
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
Add validation for pagination #4343
Comments
This is more complicated than I expected, but it might be possible. Here's an example of paginating through nulls into values with dates: To paginate through null values, users need Rather than defaulting the |
@lbeaufort Is there a way to inform users before proceeding with the query that they need to pass both? It's on us to tell them as soon as possible instead of telling them they're wrong for something they weren't aware of. That's if a 422 is an error message. |
@JonellaCulmer if I'm understanding you, yes - the plan is to send a 422, which is an error message, before running the query. https://httpstatuses.com/422 |
@JonellaCulmer after understanding your question better, I put in this follow-up issue for friendlier client-side validation in Swagger documentation: #4348 |
User story
As an API user, I want to be able to paginate through results. Paginating through Schedule A, B, and E (others? ItemizedResource) is confusing. When I mistakenly only pass
last_index
I don't get the results I'm looking for, but I can't tell why. In addition, these results are extremely slow to return.For endpoints that use
last_index
pagination, users need to provide bothlast_index
andlast_contribution_receipt date
. A quick look through the API umbrella indicates that lots of users aren't paginating correctly, and those queries are quite expensive. To be more user friendly and prevent very expensive queries, we should add API validation to ensure both these fields are provided.See https://api.open.fec.gov/developers/#/receipts/get_schedules_schedule_a_
Example:
== 1.9 seconds
vs.
== 157.5 seconds and not the intended results
Completion criteria
last_index
or just, throw a 422 and tell them they need to pass both to paginate. For now just implementing this forlast_contribution_receipt_date
last_index
as there have been almost 500K of these requests in the last few months vs. a few hundred requests missing justlast_index
.Technical steps
last_index
andsort_hide_nulls=True
. To paginate through populated values, users needlast_index
andlast_<sort_option
. Rather than defaulting thelast_
values toNone
, we should add validation/handling for this null pagination.The text was updated successfully, but these errors were encountered: