-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
Framework returns wrong response code (400) #4509
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
Comments
http://stackoverflow.com/questions/16133923/400-vs-422-response-to-post-of-data/20215807#20215807 In short, rfc 7231 obsoletes rfc 2616 and it's correct to use an http 400 response for validation errors. |
If you want to override the response code anyway, there is this section in the docs on custom exception handling. |
RFC 7231 is a proposed standard, not a standard. And even if it was, this doesn't justify that the framework responds with a |
It is technically a proposed standard, but is for all practical purposes the de facto standard. eg, the IANA points to rfc 7231 for the definition of the 400 status code. See: http://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml |
We allow plenty of scope for overriding the behavior here, but 400 is the most valid status code for validation errors. |
I'm sniffing around the 409 question. In case it gets revisited now or later, I want to address the valid questions included here:
I think the 400 trumps the 409. I don't think it makes sense to even compare an invalid client submission (400) to the current state of a resource (409). Just noticed this is actually the issue in #3381.
The concurrency issue is the "easy" answer, but here's another example that's close to something we're actually doing:
|
During certain error conditions, the
django-rest-framework
returns a wrong response code (400
).As per
RFC 2616
:This means that the syntax of the request entity is malformed, and has nothing to do with the request payload (
django-rest-framework
deals only with request payloads, not with parsing of the byte-stream producing the request).Is there any way to override this behavior to create standard-conforming HTTP APIs using the
django-rest-framework
?The text was updated successfully, but these errors were encountered: