-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Use 422 Unprocessable Entity for form deserialization errors #1681
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! Wanna add a test and changelog entry as well?
Sure, I was a bit lazy and left it out since nothing was presently testing it, but happy to add one. I'll have to sort it a little bit later though. |
That's alright. I think having a test would be good. Then its harder to break by accident. |
Ah, it looks like I spoke too soon with my assumption that the axum/axum/src/extract/raw_form.rs Lines 47 to 64 in 211de92
As such, with this change, a I'm not sure what would be the preferred solution to this? Some options I can think of:
Perhaps there are other options? |
Good catch! Another reason testing is important. I think adding another variant to |
Thanks for working on this but I think we'll move forward with #1683 |
Of course, sorry I didn't have to follow it through! |
No worries! You're welcome to give #1683 a look though :) |
Fixes #1680.
Motivation
Per #1680, we would prefer to use
422 Unprocessable Entity
responses for non-syntactic deserialization errors from theForm
extractor. This is now trivial since theForm
andQuery
rejection types were separated in #1496.Solution
status
foraxum::extract::rejection::FailedToDeserializeForm
fromBAD_REQUEST
toUNPROCESSABLE_ENTITY
.axum_extra::extract::FormRejection::FailedToDeserializeForm
for consistency.