-
Notifications
You must be signed in to change notification settings - Fork 645
Convert pagination ISE into a Bad Request response #2065
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Merged
bors
merged 3 commits into
rust-lang:master
from
jtgeibel:prod/make-2-errors-user-facing
Jan 10, 2020
Merged
Convert pagination ISE into a Bad Request response #2065
bors
merged 3 commits into
rust-lang:master
from
jtgeibel:prod/make-2-errors-user-facing
Jan 10, 2020
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11383c0
to
a0bf643
Compare
This will fix #1928 :) |
Thanks! I've updated the description to reference that issue, and cherry-picked the tests provided there. |
☔ The latest upstream changes (presumably #2032) made this pull request unmergeable. Please resolve the merge conflicts. |
Errors in parsing the pagination query string parameters can be returned to the client and do not need to propagate up to the logging middleware. The following have been observed in production logs: * error="cannot parse integer from empty string" for `/api/v1/crates?page=&per_page=50&sort=downloads` * error="invalid digit found in string" for `/api/v1/crates?page=1&per_page=100%22%EF%BC%8Cexception"`
Reviewing the source for cargo, it does not appear that there is any way to specify a `page` number and the `per_page` value is capped at 100 by cargo since at least 1.29. Showing a sub-optimal error message to very old versions of cargo seems okay.
1f53043
to
741093f
Compare
smarnach
approved these changes
Jan 10, 2020
@bors r+ |
📌 Commit 741093f has been approved by |
bors
added a commit
that referenced
this pull request
Jan 10, 2020
…nach Convert pagination ISE into a Bad Request response Errors in parsing the pagination query string parameters can be safely returned to the client and do not need to propagate up to the logging middleware. The following have been observed in production logs: * error="cannot parse integer from empty string" for `/api/v1/crates?page=&per_page=50&sort=downloads` (empty `page=`) * error="invalid digit found in string" for `/api/v1/crates?page=1&per_page=100%22%EF%BC%8Cexception"` (very invalid `per_page`) Additionally, 2 existing pagination errors are converted to use `bad_request()` in place of `cargo_err()`. It is not necessary to send a status=200 response to support old versions of cargo for pagination errors. Fixes: #1928 r? @smarnach
☀️ Test successful - checks-travis |
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Errors in parsing the pagination query string parameters can be safely returned to the client and do not need to propagate up to the logging middleware.
The following have been observed in production logs:
/api/v1/crates?page=&per_page=50&sort=downloads
(emptypage=
)/api/v1/crates?page=1&per_page=100%22%EF%BC%8Cexception"
(very invalidper_page
)Additionally, 2 existing pagination errors are converted to use
bad_request()
in place ofcargo_err()
. It is not necessary to send a status=200 response to support old versions of cargo for pagination errors.Fixes: #1928
r? @smarnach