-
Notifications
You must be signed in to change notification settings - Fork 5
problem type identifiers
Decide on recommendations for problem type identifiers: absolute URLs, relative URLs, URNs or other solution.
| requirement | explanation |
|---|---|
|
|
2. find documentation page on problem type (if provided) |
URL present, can be rewritten for reverse proxy e.g. routing
|
3a. Problem RFC standard compliance |
A URI reference [RFC3986] that identifies the problem type. Consumers MUST use the "type" string as the primary identifier for the problem type. Relative URIs must be resolved relative to the document’s base URI (= the URI to which the call is made that returned the problem) A problem’s type URI SHOULD resolve to HTML documentation that explains how to resolve the problem. |
3b. Relative URI standard compliance (rfc3986) |
Relative URIs have to be resolved from:
|
4. message complexity |
Complexity increases when more fields required in Problem JSON response |
-
Zalando REST guide: relative URLs wrt API base path. Absolute URLs if they are stable.
-
Codecentric Blog : urn:problem-type:<id> or absolute URLs if they are stable.
-
DigiPolis Antwerpen: code property as identifier, type as link to doc
-
Problem RFC 3rd party libraries expect the problem type to be stable and support any type of absolute or relative URI but don’t resolve relative URIs
-
standardized REST problems defined on absolute URIs https://www.gcloud.belgium.be/rest/problems/<id>
-
examples with relative URIs for API-specific problem types of format /problems/{problemId}; should be resolvable. Unclear if this is relative URI to API base path.
-
rule that links should always be absolute
Current Problem JSON Schema only allows absolute URIs (format: uri); though some OpenAPI tooling doesn’t validate this strictly. format: uri-reference would both allow relative and absolute URIs
| Option | Example | description |
|---|---|---|
1) code field |
|
use "type" only for documentation and new "code" property as identifier (~ DigiPolis Antwerpen) |
2) absolute URNs |
|
(~ Codecentric blog)
|
3) type as string |
|
3a) relative link wrt API base path ~ Zalando REST guide. 3b) relative link includes API base path (without domain name) |
4) absolute URLs only (env-dependent) |
|
Clients should parse the type value and use the last part to use as identifier |
| Option | stable identifier | retrieve doc | Problem RFC standard | relative URI standard | message complexity |
|---|---|---|---|---|---|
1 code field |
+ |
+ |
— |
+ |
- |
2 URN |
+ |
+ (typeHref) |
+ |
+ |
- |
3a string ID w/o base URI |
+ |
+ |
- |
- |
+ |
3b string ID with base URI |
- (*) |
- (*) |
- |
+ |
+ |
4 absolute URL |
- - |
+ |
+ |
+ |
+ |
(*) dependency on technical part in URL, that may change by reverse proxies or tech changes
Impact when requirement not satisfied:
-
stable identifier: high
-
retrieve doc: medium (low?)
-
Problem RFC standard:
-
resolve relative URIs before using them as identifiers: low - everything continues to work when not resolving relative URIs when using them as identifier
-
using another field then type as identifier: high
-
-
relative URI standard: low - API clients and servers often construct the paths based on API’s base URI
-
message complexity: medium
Option 2 was chosen during meeting 29/3.
An additional requirement was raised: low risk on faulty implementation. This exists when resolving relative URIs (both in 3a and 3b). This is the reason why relative URIs are discouraged in the REST guide in the first place.
Note that we explicitly have chosen not follow this recommendation in Problem RFC: "A problem’s type URI SHOULD resolve to HTML documentation that explains how to resolve the problem." This in order to be able to represent API-specific problem types.
The option 2 will be applied to all problem types, even the ones standardized in G-Cloud, to avoid any confusion.
Examples:
{
"type": "urn:problem-type:cbss:socialStatus:searchCriteriaTooWide",
"href": "https://api.ksz-bcss.fgov.be/socialStatus/v2/refData/problems/urn:problem-type:cbss:socialStatus:searchCriteriaTooWide",
"status": 400,
"title": "Search criteria should be more specific"
}{
"type": "urn:problem-type:belgif:payloadTooLarge",
"instance": "urn:uuid:abcdefghij-1234-1234-adfkjddd",
"href": "https://www.gcloud.belgium.be/rest/refData/problemTypes/urn:problem-type:belgif:payloadTooLarge", #location might change in the future
"status": 413,
"title": "Payload Too Large",
"detail": "Request message must not be larger than 10 MB",
"limit": 10485760
}Recommended structure:
-
urn:problem-type:<org>:<api>:<type> OR urn:problem-type:<org>:<type>
-
prefix urn:problem-type because already used by others in practice
-
<org> short identifier for organization (no reverse FQDN because often too long)
-
<api> MAY be used for API-local problem types
-
<type> lowerCamelCase string identifying the type
-
reason lowerCamelCase instead of hyphen-case: URIs more commonly hyphen, but API and other REST guidelines use lowerCamelCase
-
-
-
optional href linking to problem description HTML
-
href instead of typeHref because shorter, and low risk on confusion with HTML for specific problem instance
-
in link, use full problem URN as the resource id
-
-
instance should be URI (conform to spec; most of the time urn:uuid:<uuid>)