Skip to content
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

Repository of common Problem types #7

Closed
sazzer opened this issue Jan 29, 2021 · 17 comments · Fixed by #24
Closed

Repository of common Problem types #7

sazzer opened this issue Jan 29, 2021 · 17 comments · Fixed by #24
Assignees

Comments

@sazzer
Copy link

sazzer commented Jan 29, 2021

(I'm not sure if this is the correct place to propose this, so apologies if not!)

As RFC-7807 gains wider-spread adoption, it is becoming the case that more and more APIs are returning effectively the same problems with different values for the fields. This makes it difficult to work across different APIs, because you need to understand that different problems from those APIs actually mean the same thing.

Common examples that you might expect to see include:

  • Resource not found
  • Authentication failure
  • Optimistic lock failure (e.g. the If-Match header on a PUT request has the wrong value)
  • Request validation failure

It seems that it would be useful to have a repository of these common problem types that can then be reused across APIs, so that ideally these common situations can be handled in the exact same way on the client.

Effectively the same idea as the standard list of Link Relations, whereby all clients that see a link relation of, for example, self or item know what they mean regardless of the API that produced them.

@sdatspun2
Copy link
Collaborator

Unlike relation type name (self or item), problem type` is a URI in 7807. Is there any other example of a repository of entities where each entity is uniquely addressable?

Also, I am working on API for such a repository https://github.com/sdatspun2/error-catalog-service (When you read, replace "Error Type" with "Problem Type" and "Error Catalog" with "Problem Type Repository"). I would like to submit it here to evolve it if there is interest.

@sazzer
Copy link
Author

sazzer commented Jan 31, 2021 via email

@mnot
Copy link
Member

mnot commented Feb 1, 2021

There are a couple of ways to go here:

  1. Create an IANA registry of problem types, much as for link relations.
  2. Create a publicly-coordinated informal repository (eg, in a wiki).

Because types are required to be URIs, avoiding conflicts (one of the main reasons to use a registry) isn't relevant; it would be more to aid discovery. If we wanted some sort of quality filter on it, we'd probably use an IANA registry, and would need a process around that (e.g., expert review, IETF review; see RFC8126 Section 4).

Note that 7087 allows relative URIs in the type field, we couldn't use bare tokens like link relations do. However, if folks wanted "neutral" URIs that didn't reflect a particular vendor, we could easily mint URIs in a common name space like urn:ietf:params:http-problems:foo or https://httpwg.org/http-problems/foo or something else.

P.S. Resource Not Found and Authentication Failure are already HTTP status codes -- 404 and 401, respectively (unless you mean non-HTTP auth in the latter case).

@sazzer
Copy link
Author

sazzer commented Feb 4, 2021

P.S. Resource Not Found and Authentication Failure are already HTTP status codes -- 404 and 401, respectively (unless you mean non-HTTP auth in the latter case).

These are already HTTP status codes, but it's not unreasonable for APIs to want to always return a Problem response for any error. Sometimes it's easier to develop the server code that way (e.g. in Rust it's very verbose to have many different response types.) Sometimes it's easier to allow clients to always assume an application/problem+json response. Sometimes it's just that people like consistency. And actually the only real downside seems to be that the response payload is non-zero in size

Given that though, it means that people start to mint URIs for problem types that directly correspond to HTTP status codes. And, odds are, different people do it differently. That's a key example where some standard values would just make that a little bit easier. For example, I've started using values like https://httpstatuses.com/404 in these cases - it doesn't actually tell you anything more than the HTTP status code, but it means that the response body is always in a consistent format which just makes life that little bit easier in some cases. (I did consider a link to the appropriate section of RFC-7232, but that seemed a bit more awkward given that it would need a fragment in the URI)

@mnot
Copy link
Member

mnot commented Feb 4, 2021

The RFC recommends that about:blank be used in this situation. We intentionally did not have per-status-code values, because that would encourage developers to ignore the real status code, and because duplicating values at different layers is a vector for bugs and security issues.

@sazzer
Copy link
Author

sazzer commented Feb 4, 2021 via email

@mnot
Copy link
Member

mnot commented Feb 10, 2021

For "standard" problem types, would folks be willing to stomach the urn:ietf:params:http-problems:foo form? That's likely the most permanent, easy way to do it.

Using httpwg.org is also possible, as would be ietf.org. Some might complain that they (especially the former) are rooted in DNS, and therefore might not be stable over a long time scale.

Another option would be minting our own URI scheme, to make something like http-problem:foo. That might make some of the URN folks unhappy, though; would have to try to find out.

@asbjornu
Copy link
Contributor

I think we need to resolve #11 before we can decide on the format.

@sazzer
Copy link
Author

sazzer commented Feb 10, 2021

I guess the form we go for depends on some other things. If we decide (per #11 as @asbjornu says) that the value should be a URI, and that it should resolve to documentation, then something like https://httpwg.org/problems/foo might be better. But then, as you say, that means that URL has to remain stable for the foreseeable future.

Personally speaking, I'm fine with the urn:ietf:params:http-problems:foo idea - I currently always use tag:xxx,2021:foo for mine anyway - but it does mean that they are definitely not resolvable.

I'm less keen on the idea of a new scheme. It is obvious what's happening, but it does start to look like all problems must be in that scheme, which then potentially defeats the point of #11 in the first place. Also, (and I might be missing things here) it seems that the only real benefit of http-problem:foo over urn:ietf:params:http-problems:foo is in the length of the string, which isn't a huge deal - it's a saving of 17 characters.

@mnot
Copy link
Member

mnot commented Mar 15, 2021

In the meeting, folks seemed to pretty strongly lean towards an IANA registry with some bar to entry (TBD).

@mnot
Copy link
Member

mnot commented Jul 14, 2021

See #24 for a proposal.

@dret
Copy link
Collaborator

dret commented Jul 16, 2021

thanks for #24 , @mnot! i like it, but my concern is a bit that if we have a registry, wouldn't it make more sense to suggest using a URN scheme or a URN pattern (urn:ietf:params:http-problems was proposed above) for registered type? the registry specifically is there for discovery, so we don't have to use HTTP URIs which create the risk of tooling accessing those URIs and creating unnecessary load.
my personal preference would be to go the URN way (scheme or pattern) and maybe add a section on discovery, which would then point out these alternatives: if you use custom types, you have to think about discovery. if you think about registering types, then discovery is taken care of by the registry, so using a non-dereferencable URI may be the better option to choose.

@mnot
Copy link
Member

mnot commented Jul 19, 2021

@dret see discussion in #15.

@dret
Copy link
Collaborator

dret commented Jul 20, 2021 via email

@dret
Copy link
Collaborator

dret commented Jul 21, 2021

just in case anybody is interested in a general discussion of why and how to use registries, here's something i wrote a while ago that discusses various aspects of the general pattern: https://datatracker.ietf.org/doc/html/draft-wilde-registries-03

@mnot
Copy link
Member

mnot commented Jul 27, 2021

Discussed in 111: no strong feelings about URI scheme; a bit of preference for urn.

@mnot
Copy link
Member

mnot commented Jul 29, 2021

I'm going to go ahead and merge as is; we can address the URI scheme part as our thinking on that develops.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants