@@ -44,15 +44,23 @@ strings **may** change over time; however, if an error message does not have a
4444machine-readable identifier _ in addition to_ the ` code ` field, changing the
4545error message ** must** be considered a backwards-incompatible change.
4646
47- ** Note:** The [ ` ErrorInfo ` ] [ ErrorInfo ] message is the recommended way to send a
48- machine-readable identifier.
47+ #### ErrorInfo
48+
49+ The [ ` ErrorInfo ` ] [ ErrorInfo ] message is the required way to send a
50+ machine-readable identifier. All error responses ** must** include an
51+ ` ErrorInfo ` payload in the ` details ` field. Variable information
52+ ** should** be included in the ` metadata ` field on ` ErrorInfo ` and
53+ ** must** be included if it appears within an error message.
4954
5055#### Uniqueness
5156
5257Each type of detail payload ** must** be included at most once. For
53- example, there ** must not** be more than one ` ErrorInfo ` message in the
54- ` details ` field, but there ** may** be an ` ErrorInfo ` and a
55- [ ` PreconditionFailure ` ] [ PreconditionFailure ] .
58+ example, there ** must not** be more than one [ ` BadRequest ` ] [ BadRequest ]
59+ message in the ` details ` field, but there ** may** be a ` BadRequest ` and
60+ a [ ` PreconditionFailure ` ] [ PreconditionFailure ] .
61+
62+ ** Note:** ` ErrorInfo ` represents a special case. There ** must** be exactly one
63+ ` ErrorInfo ` . It is required.
5664
5765### Localization
5866
@@ -86,13 +94,29 @@ if the resource or parent exists.
8694If the user does have proper permission, but the requested resource or parent
8795does not exist, the service ** must** error with ` NOT_FOUND ` (HTTP 404).
8896
97+ ## Rationale
98+
99+ ` ErrorInfo ` is required because it further identifies an error. The
100+ ` Status ` field, with under 20 [ allowed values] [ Code ] , is rarely enough
101+ to disambiguate one error from another accross an entire API Service.
102+ Error messages often contain dynamic segments that express values, such
103+ as project numbers or locations, and these values are often read from
104+ the string message using brittle extraction methods, like RegExp. There
105+ needs to be a machine readable component of * every* error response that
106+ enables clients to pull such information programatically--without
107+ parsing the string error message. For these reasons, ` ErrorInfo ` is
108+ required for * every* error response.
109+
89110## Further reading
90111
91112- For which error codes to retry, see [ AIP-194] ( https://aip.dev/194 ) .
92- - For how to retry errors in client libraries, see [ AIP-4221] ( https://aip.dev/client-libraries/4221 ) .
113+ - For how to retry errors in client libraries, see
114+ [ AIP-4221] ( https://aip.dev/client-libraries/4221 ) .
93115
94116## Changelog
95117
118+ - ** 2023-05-10** : Require [ ` ErrorInfo ` ] [ ErrorInfo ] for all error
119+ responses.
96120- ** 2023-05-04** : Require uniqueness by message type for error details.
97121- ** 2022-11-04** : Added guidance around PERMISSION_DENIED errors previously
98122 found in other AIPs.
@@ -108,6 +132,7 @@ does not exist, the service **must** error with `NOT_FOUND` (HTTP 404).
108132[ details ] : https://github.com/googleapis/googleapis/blob/master/google/rpc/error_details.proto
109133[ ErrorInfo ] : https://github.com/googleapis/googleapis/blob/6f3fcc058ff29989f6d3a71557a44b5e81b897bd/google/rpc/error_details.proto#L27-L76
110134[ PreconditionFailure ] : https://github.com/googleapis/googleapis/blob/6f3fcc058ff29989f6d3a71557a44b5e81b897bd/google/rpc/error_details.proto#L139-L166
135+ [ BadRequest ] : https://github.com/googleapis/googleapis/blob/477a59d764428136ba1d857a9633c0d231de6efa/google/rpc/error_details.proto#L168-L218
111136[ grpc status code documentation ] : https://github.com/grpc/grpc/blob/master/doc/statuscodes.md
112137[ Code ] : https://github.com/googleapis/googleapis/blob/master/google/rpc/code.proto
113138[ Status ] : https://github.com/googleapis/googleapis/blob/master/google/rpc/status.proto
0 commit comments