AddProblemDetailsConventions changes HTTP 400 to 422
See original GitHub issueWithout AddProblemDetailsConventions
, a request with an invalid model returns HTTP response code 400. With AddProblemDetailsConventions
, the same request returns 422.
Possibly related to #125.
Issue Analytics
- State:
- Created a year ago
- Comments:17 (9 by maintainers)
Top Results From Across the Web
[Docs] Purpose of ProblemDetails library · Issue #149
I just noticed this change from HTTP 400 to 422 myself. I agree that 422 is better for validation errors, but would like...
Read more >Hellang.Middleware.ProblemDetails error mapping
Error 400 says the request is not formed correctly like something is wrong with the body or headers. Error 422 says that there...
Read more >Problem Details for Better REST HTTP API Errors
This first example is using a Status Code of 400 Bad Request, which is good. They provide a response body that has a...
Read more >An opinionated way to consistent Error Handling in ASP.NET ...
In this post, I have explained an opinionated way to achieve consistent error handling for your ASP.NET Core through Error response object.
Read more >Page 34 of 141 - Software Architecture & Design - CodeOpinion
Sure an HTTP 400 status code tells the client that there's an issue, but what exactly is the issue? ... It should NOT...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
See https://github.com/khellang/Middleware/issues/149#issuecomment-1022156162.
You can set
ValidationProblemStatusCode
back to 400 of you want:https://github.com/khellang/Middleware/blob/a81989f16c83c286d1c2fee2e956b27b3243663b/src/ProblemDetails/ProblemDetailsOptions.cs#L133-L136
There’s a domain-specific language layered on top of the JSON. The syntax of that language is expressed in the semantic content of the JSON. Model binding and validation are responsible for validating that syntax. Model binding and validation are in absolutely no way concerned with the semantic content of that language. From the perspective of the controller and service layers, as well as the client, any error that occurs during model binding and validation is a syntax error. This is the sense in which “syntax” should be understood in RFC4918. Logically, this inevitably follows from recognizing that the schema is a language. Pragmatically, it creates an elegant separation of concerns that is neatly reflected in the response codes.
Normalizing returning 422 for errors in model binding and validation will harm the Internet.