Skip to content

Commit 633e507

Browse files
authored
address comment by updating problem schema (#855)
1 parent a8ffd42 commit 633e507

File tree

2 files changed

+59
-92
lines changed

2 files changed

+59
-92
lines changed

chapters/http-status-codes-and-errors.adoc

Lines changed: 38 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -461,16 +461,16 @@ proper guidance for handling batch/bulk requests and responses, we herewith
461461
define the following approach:
462462

463463
* A batch or bulk request *always* responds with HTTP status code {207}
464-
unless a non-item-specific failure occurs.
464+
unless a non-item-specific failure occurs.
465465

466466
* A batch or bulk request *may* return {4xx}/{5xx} status codes, if the
467-
failure is non-item-specific and cannot be restricted to individual items of
468-
the batch or bulk request, e.g. in case of overload situations or general
469-
service failures.
467+
failure is non-item-specific and cannot be restricted to individual items of
468+
the batch or bulk request, e.g. in case of overload situations or general
469+
service failures.
470470

471471
* A batch or bulk response with status code {207} *always* returns as payload
472-
a multi-status response containing item specific status and/or monitoring
473-
information for each part of the batch or bulk request.
472+
a multi-status response containing item specific status and/or monitoring
473+
information for each part of the batch or bulk request.
474474

475475
**Note:** These rules apply _even in the case_ that processing of all
476476
individual parts _fail_ or each part is executed _asynchronously_!
@@ -529,23 +529,23 @@ providing further details to the client. There are two approaches a service
529529
can take for header information:
530530

531531
* Return a {Retry-After} header indicating how long the client ought to wait
532-
before making a follow-up request. The Retry-After header can contain a HTTP
533-
date value to retry after or the number of seconds to delay. Either is
534-
acceptable but APIs should prefer to use a delay in seconds.
532+
before making a follow-up request. The Retry-After header can contain a HTTP
533+
date value to retry after or the number of seconds to delay. Either is
534+
acceptable but APIs should prefer to use a delay in seconds.
535535
* Return a trio of `X-RateLimit` headers. These headers (described below) allow
536-
a server to express a service level in the form of a number of allowing
537-
requests within a given window of time and when the window is reset.
536+
a server to express a service level in the form of a number of allowing
537+
requests within a given window of time and when the window is reset.
538538

539539
The `X-RateLimit` headers are:
540540

541541
* `X-RateLimit-Limit`: The maximum number of requests that the client is
542-
allowed to make in this window.
542+
allowed to make in this window.
543543
* `X-RateLimit-Remaining`: The number of requests allowed in the current
544-
window.
544+
window.
545545
* `X-RateLimit-Reset`: The relative time in seconds when the rate limit window
546-
will be reset. **Beware** that this is different to Github and Twitter's
547-
usage of a header with the same name which is using UTC epoch seconds
548-
instead.
546+
will be reset. **Beware** that this is different to Github and Twitter's
547+
usage of a header with the same name which is using UTC epoch seconds
548+
instead.
549549

550550
The reason to allow both approaches is that APIs can have different
551551
needs. Retry-After is often sufficient for general load handling and
@@ -568,63 +568,21 @@ number of requests made within a given window for each named entity.
568568
errors in API responses. It serves several purposes:
569569

570570
* Developers: to debug, diagnose and resolve issues during API integration or
571-
operation
571+
operation
572572
* Client applications: to inform users about errors (in user interface) and to
573-
support automated processing and error handling when appropriate.
573+
support automated processing and error handling when appropriate.
574574

575-
==== Problem schema members, suppported by the API guidelines
576-
Problem detail objects can have the following members.
575+
==== Problem schema members, supported by the API guidelines
576+
Problem detail objects can have the following members described in the OpenAPI
577+
schema definition
578+
https://opensource.zalando.com/restful-api-guidelines/models/problem-1.0.1.yaml[on
579+
GitHub].
577580

578581
**Note:** If a member's value type does not match the specified type,
579582
the member MUST be ignored -- i.e., processing will continue as if
580583
the member had not been present.
581584

582-
===== status (integer)
583-
The HTTP status code generated by the origin server for occurrences of the problem.
584-
Example:
585-
586-
`"status": 400`
587-
588-
===== title (string)
589-
A short, human-readable summary of the problem type. It *SHOULD NOT* change
590-
from occurrence to occurrence of the problem, except for purposes of
591-
localization.
592-
Example:
593-
594-
`"title": "Invalid parameter"`
595-
596-
===== detail (string)
597-
A human-readable explanation specific to this occurrence of the problem.
598-
Provides additional context or specifics about the error for debugging
599-
or display to the user.
600-
Example:
601-
602-
`"detail": "The 'color' parameter is invalid"`
603-
604-
===== type and instance (URI references)
605-
The standardized Problem JSON object also allows for the following optional
606-
members:
607-
608-
- type: a URI identifying the problem type, typically more specific than the
609-
HTTP status code. In many cases, an error code can be placed in the type
610-
property. It may support automated client decisions in certain failure modes.
611-
If the `type` doesn’t provide additional information, it can be omitted
612-
(defaulting to `"about:blank"`).
613-
- instance: a URI reference that identifies specific occurrence of the problem.
614-
This field should serve the purpose of defining a clear error instance from
615-
which the developer can determine the source location of the error.
616-
Additionally, it may include relevant contextual information, such as parameters
617-
associated with the error and optionally `Flow-ID` for debugging purposes.
618-
619-
Examples:
620-
621-
`"type": "https://example.com/errors/invalid-parameter"`
622-
623-
`"type": "https://example.com/errors/ERR12345" (with error code)`
624-
625-
`"instance": "/errors/12345"`
626-
627-
*Note:* {RFC-9457}[RFC 9457] encourages that problem types are URI
585+
{RFC-9457}[RFC 9457] encourages that problem types are URI
628586
references that point to human-readable documentation, *but* we deliberately
629587
decided against that, as all important parts of the API must be documented
630588
using <<101, OpenAPI>> anyway. In addition, URLs tend to be fragile and not
@@ -644,7 +602,7 @@ identifiers in `type` and `instance` fields:
644602
*Hint:* The use of https://tools.ietf.org/html/rfc3986#section-4.3[absolute
645603
URIs] is not forbidden but strongly discouraged. If you use absolute URIs,
646604
please reference
647-
https://opensource.zalando.com/restful-api-guidelines/models/problem-1.0.0.yaml#/Problem[problem-1.0.0.yaml#/Problem]
605+
https://opensource.zalando.com/restful-api-guidelines/models/problem-1.0.1.yaml#/Problem[problem-1.0.1.yaml#/Problem]
648606
instead.
649607

650608
==== Usage of Problem Object
@@ -654,9 +612,9 @@ properties being present or having specific values.
654612
The examples of such cases are:
655613

656614
- response might be created by infrastructure components (and have a different
657-
response format, comparing to the guidelines)
615+
response format, comparing to the guidelines)
658616
- response might be created by a service that is unable to comply with the
659-
guidelines due to certain error situations
617+
guidelines due to certain error situations
660618

661619
In cases where the Problem Object lacks the required information, clients must
662620
implement fallback mechanisms, defaulting to reasonable behavior similar to
@@ -694,21 +652,21 @@ The following guidelines offer best practices for utilizing type in automated
694652
processing:
695653

696654
1. Property `type` may be used by clients to make automatic decisions in
697-
certain failure modes. The `title` property serves as a concise,
698-
human-readable summary of the type. It is particularly helpful for debugging
699-
and serves as an engineer-readable shorthand for the problem type.
655+
certain failure modes. The `title` property serves as a concise,
656+
human-readable summary of the type. It is particularly helpful for debugging
657+
and serves as an engineer-readable shorthand for the problem type.
700658

701659
2. Clients may use these fields to drive automated actions if the API
702-
explicitly defines the semantics of `type` and `instance` and enumerates
703-
stable values. This can be achieved by extending the Problem JSON object and
704-
associating an x-extensible-enum with the type property.
660+
explicitly defines the semantics of `type` and `instance` and enumerates
661+
stable values. This can be achieved by extending the Problem JSON object and
662+
associating an x-extensible-enum with the type property.
705663

706664
3. Clients must handle scenarios where the type is absent or unrecognized and
707-
fallback to default behaviors.
665+
fallback to default behaviors.
708666

709667
4. For collections of related APIs, using shared type values for similar errors
710-
and distinct values for different errors simplifies automated processing and
711-
error handling for clients working across APIs.
668+
and distinct values for different errors simplifies automated processing and
669+
error handling for clients working across APIs.
712670

713671
*Note:* Include descriptions for each known error that can happen directly in
714672
the specification or reference external documentation to clarify their meanings
@@ -788,9 +746,9 @@ redirection to migrate clients to a new service location. However, this is
788746
better accomplished by one of the following.
789747

790748
1. Changing the clients to use the new location in the first place, avoiding
791-
the need for redirection.
749+
the need for redirection.
792750
2. Redirecting the traffic behind the API layer (e.g. in the reverse proxy or
793-
the app itself) without the client having to be involved.
751+
the app itself) without the client having to be involved.
794752
3. Deprecating the endpoint and removing it as described in <<deprecation>>.
795753

796754
For idempotent {POST} cases, where you want to inform the client that a resource

models/problem-1.0.1.yaml

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,23 @@ Problem:
55
type: string
66
format: uri-reference
77
description: >
8-
A URI reference that uniquely identifies the problem type only in the
9-
context of the provided API. Opposed to the specification in RFC-9457,
10-
it is neither recommended to be dereferenceable and point to a
11-
human-readable documentation nor globally unique for the problem type.
8+
An optional member, URI identifying the problem type, typically more
9+
specific than the HTTP status code. In many cases, an error code can be
10+
placed in the type property. It may support automated client decisions
11+
in certain failure modes. If the type doesn’t provide additional
12+
information, it can be omitted (defaulting to `"about:blank"`).
1213
default: 'about:blank'
13-
example: '/some/uri-reference'
14+
examples:
15+
- 'https://example.com/errors/invalid-parameter'
16+
- 'https://example.com/errors/ERR12345' # with error code
1417
title:
1518
type: string
1619
description: >
17-
A short summary of the problem type. Written in English and readable
18-
for engineers, usually not suited for non technical stakeholders and
19-
not localized.
20-
example: some title for the error situation
20+
A short, human-readable summary of the problem type. It *SHOULD NOT*
21+
change from occurrence to occurrence of the problem. Written in English
22+
and readable for engineers, usually not suited for non-technical
23+
stakeholders and not localized.
24+
example: 'Invalid parameter'
2125
status:
2226
type: integer
2327
format: int32
@@ -27,19 +31,24 @@ Problem:
2731
minimum: 100
2832
maximum: 600
2933
exclusiveMaximum: true
34+
example: 400
3035
detail:
3136
type: string
3237
description: >
3338
A human readable explanation specific to this occurrence of the
3439
problem that is helpful to locate the problem and give advice on how
3540
to proceed. Written in English and readable for engineers, usually not
3641
suited for non technical stakeholders and not localized.
37-
example: some description for the error situation
42+
example: 'The \"color\" parameter is invalid'
3843
instance:
3944
type: string
4045
format: uri-reference
4146
description: >
4247
A URI reference that identifies the specific occurrence of the problem,
4348
e.g. by adding a fragment identifier or sub-path to the problem type.
44-
May be used to locate the root of this problem in the source code.
45-
example: '/some/uri-reference#specific-occurrence-context'
49+
This field should serve the purpose of defining a clear error instance
50+
from which a developer can determine the source location of the error.
51+
Additionally, it may include relevant contextual information, such as
52+
parameters associated with the error and optionally `Flow-ID` for
53+
debugging purposes.
54+
example: '/errors/12345'

0 commit comments

Comments
 (0)