Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AddProblemDetailsConventions changes HTTP 400 to 422

See original GitHub issue

Without 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:closed
  • Created a year ago
  • Comments:17 (9 by maintainers)

github_iconTop GitHub Comments

kjkrumcommented, Jun 22, 2022

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found