-
Notifications
You must be signed in to change notification settings - Fork 391
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
Improvements for Problem guideline (176) #763
Comments
Adding my opinions:
|
I tried to dump a few thoughts on this without going through the whole discussion, so feel free to just skip over this and treat it as a brain dump. I'll try to go through the discussion and reconcile it with my thoughts in a bit :)
Currently the spec heavily leans towards it being for developers. I'd tend to mostly agree there. The errors the API returns likely have to be interpreted and provided with the right messaging in the right context for them to be useful when embedded into a frontend. For apps facing a huge audience of diverse customers (e.g. Fashion Store), this seems critical and we should just display "Unknown error" + reference they can provide for debugging. For cases where the customer can actually do something about it, it should be a special case that looks at the Problem For apps with a specific known audience, e.g. employees, displaying the
I'd say if there is an obvious automatic processing decision that can be taken (e.g. retry), the client can use
I don't think they should be standardized across APIs and they don't necessarily need to be documented, unless they can/should be used for the automated decision making in the client. The different cases could be listed as different responses in the API spec, perhaps highlighting the type in the description?
Yes, but I think in that case it should be documented in the API spec (or rather, vice versa), see 2a.
Yes. It's also good to differentiate between textual error codes and numerical error codes.
It seems difficult implement in many cases, but to me it seems like an identifier that points to a specific individual request error. E.g.
I understand it more as the latter. The former I'd capture as a custom message in
It seems a bit of an edge case, but it might be useful for debugging specific requests (e.g. looking up matching logs or traces).
I think it's better to have a default fallback. It's not so bad for developers without one, but if you are exposing this to users e.g. for internal apps, you have to otherwise implement a fallback in the client, which is less ideal. In fact, I think for some cases you should always have the default / static type, e.g. for internal server errors, as it seems very unlikely that the client could make automated decisions based on internal API state, but I might be missing something.
I'd say the API spec should be the deciding factor. If it's documented to return a specific type, it shouldn't change that behavior. Of course, in the real world it's a bit messier, so I would always try to keep The human readable messages (
Not sure. There are two extensions I can think of off the top of my head, not sure if the guidelines have anything on these.
That seems sensible, but I'd only do that if it's really needed to drive a business case as otherwise it can get complicated very quickly.
I don't see a big problem here, it's the same as other API responses. All extensions should only add fields, not change existing ones. Then consumers of the problems either just handle the generic problems or have the code to handle specific ones too. Extra unhandled fields should be ignored as per the usual with JSON parsing.
I think this is on a case-by-case basis. Other points already touch on this quite a bit. |
That's a good way to list them! I'd go with descriptions first as just the types can be endpoint-specific and are probably hard to interpret out of context (just in the enum itself).
I'm finding it difficult to see cases of two APIs being so similar that they share the same errors and even further that the clients can respond to the errors in the same way across multiple APIs. I'd tread carefully here as it seems easy to make assumptions on error semantics leading to unexpected behavior (= incidents) later. Did you have some specific examples in mind here?
Yeah that's a good point, there should always be an "unknown error" fallback on the client-side as well to handle cases where you e.g. don't even get JSON. At the same time, it seems useful to also implement fallbacks in the application for common cases (e.g. internal errors), so that you get a little more detail.
There are two cases.
I don't know if it makes sense to differentiate between them, but it might be useful for engineers at least?
I'm not sure what this means exactly. If the client can't rely on e.g. "wrong price" being returned when the "price" constraint fails to show the right localized error message, what's the point in even having |
tl;dr: After going through the discussion, it seems the guidelines and/or the Problem schema would benefit from additional examples and explanation to make it clearer how to use the different fields and when. I would discourage extending the Problem object to keep it simple. If it's really really needed then sure, but it should be a high bar. Two cases I can think of to look into might batch/bulk and hierarchical problems. I'd love to see more use-cases if any though, because I might be missing something. |
My 2 cents on this issue:
|
@tfrauenstein I think you agreed a few month back to compile these suggestions into some kind of proposal. |
hint: pls. see also API Guild Initial discussion from May and RFC discussion from September |
We discovered that our current guideline about problem/json is interpreted somewhat differently (both between guild members, and by other developers in the company).
Some things to clarify (most related to each other):
type
(+title
) member, compared to the status code?instance
field?type
+title
) be filled with default values replicating the status code information, or just be left empty/missing?type
value is returned?type
as a discriminator for subtyping?(Also, if we are looking at this guideline: Fix the typo
instant
→instance
in the first paragraph.)The text was updated successfully, but these errors were encountered: