-
Notifications
You must be signed in to change notification settings - Fork 20
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
No error messages in 200-299 statuses #25
Comments
I saw this today { |
This one is interesting. We're using an API call to get status fields for various form inputs, 200 OK meaning all's good (session checks out, states match etc. and there is a non-empty response to show), yet there's While I understand the idea, does it always mean that any "error" or "fail" or "decline" negative values or fields mean the operation itself is not actually doing its expected job? |
Thanks for rasinging this, because the questsions you'are asking are exactly what the rule is meant to expose. The operation is whatever the user is trying to do, and if there are failures in whatever they are trying to do then whatever they are trying to do has failed. Errors are not just for server mistakes or JSON syntax errors. That would be subduing most of the purpose of most of the functionality in HTTP, treating it like a daft RPC pipe only able to say if the pipe is working. Beyond that, returning errors on 200 means all monitoring software has to be specially trained to look for your Let's get this rule added, and point to this blog post when we do it. https://apisyouwonthate.com/blog/useful-api-errors-for-rest-graphql-and-grpc |
Great. (Dumb RPC pipe is what I struggle with, day-to-day. Spot on!) — So I guess the short answer to my doubts about such cases is actually the intended outcome: the style lint tells me to think about it more broadly… and maybe get beyond the HTTP (=transport) meaning, think more about 422s and adopt own system of problem+json even for "business logic" outputs, where an error payload is the expected happy path of the endpoint. Sweet. |
Make sure the response object for any 200-299 response code does not contain any of the following properties:
It should also not contain these:
status: false
status: "error"
If you can think of any other common error properties that would definitely be errors, feel free to bung them in too.
The text was updated successfully, but these errors were encountered: