Skip to content

Commit b119f8a

Browse files
committed
AIP-193: Update the LocalizedMessage section
Note that we don't currently (as far as I'm aware) have a good standardized way of letting users specify a locale. (Can they use Accept-Language, for example? What about in gRPC?) We can tackle that separately. This commit changes the guidance in a couple of important ways: - It says that the locale should be a user-specified one rather than a "service's native language" - It calls out the ability to use LocalizedMessage even when we don't have a user-specified language, when Status.message can't be changed for compatibility reasons This commit *doesn't* address the issue of the target audience of LocalizedMessage; later text claims this is aimed at end-users whereas Status.message is more aimed at developers. I'm not convinced by that at the moment.
1 parent 4cb8766 commit b119f8a

1 file changed

Lines changed: 30 additions & 48 deletions

File tree

aip/general/0193.md

Lines changed: 30 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -172,55 +172,37 @@ The set of keys provided in each (reason, domain) pair is independent from other
172172
but services **should** aim for consistent key naming. For example, two error reasons
173173
within the same domain should not use metadata keys of `vmType` and `virtualMachineType`.
174174

175-
#### Localization
176-
177-
If a localized error message is required, the service **must** include
178-
[`google.rpc.LocalizedMessage`][LocalizedMessage] in `Status.details`.
179-
The value of the `Status.message` string **should** be presented in the
180-
service's native language in the `LocalizedMessage.message` string,
181-
while also ensuring that the `locale` string shows the correct language.
182-
183-
#### LocalizedMessage payload
184-
185-
The LocalizedMessage payload **should** contain the complete resolution
186-
to the error. If more information is needed than can fit in this
175+
#### LocalizedMessage
176+
177+
[`google.rpc.LocalizedMessage`][LocalizedMessage] is used to provide an error
178+
message which **should** be localized to a user-specified locale where
179+
possible.
180+
181+
If the [`Status.message`](#status-message) field has a sub-optimal value
182+
which cannot be changed due to the constraints in the
183+
[Changing Error Messages](#changing-error-messages) section, `LocalizedMessage`
184+
**may** be used to provide a better error message even when no user-specified
185+
locale is available.
186+
187+
Regardless of how the locale for the message was determined, both the `locale`
188+
and `message` fields **must** be populated.
189+
190+
The `locale` field specifies the locale of the message,
191+
following [IETF bcp47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt) (Tags for
192+
Identifying Languages). Example values: `"en-US"`, `"fr-CH"`, `"es-MX"`.
193+
194+
The `message` field contains the localized text itself. This
195+
**should** include a brief description of the error and a call to action
196+
to resolve the error. The message **should** include contextual information
197+
to make the message as specific as possible. Any contextual information
198+
in the message **must** be included in `ErrorInfo.metadata`. See
199+
[`ErrorInfo`](#errorinfo) for more details of how contextual information
200+
may be included in a message and the corresponding metadata.
201+
202+
The `LocalizedMessage` payload **should** contain the complete resolution
203+
to the error. If more information is needed than can reasonably fit in this
187204
payload, then additional resolution information **must** be provided in
188-
the Help payload. See the [Help payload](#help-payload)
189-
section for guidance.
190-
191-
For pre-existing (brownfield) APIs, the content in this `message` string
192-
will differ from the `message` string in `google.rpc.status`.
193-
194-
[LocalizedMessage Payload][LocalizedMessage]
195-
196-
Details of this object are summarized in the following fields, field
197-
descriptions, and examples:
198-
199-
- `locale string`
200-
- The locale that follows the specification defined in [IETF
201-
bcp47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt) (Tags for
202-
Identifying Languages).
203-
- *Example*: **"en-US"**, **"fr-CH"**, **"es-MX"**
204-
- `message string`
205-
- The error message that the customer will receive through their
206-
chosen service, which **should** include a brief description of the
207-
error and a call to action to resolve the error. The message
208-
**should** include, where needed, data provided in other fields such
209-
as metadata.
210-
- Give users clear and concise instructions for resolving the error,
211-
which **must** be explicit as possible; for example:
212-
213-
> Consider trying your request in the <AVAILABLE-ZONE-1>,
214-
> <AVAILABLE-ZONE-N> zone(s), which currently has/have capacity to
215-
> accommodate your request. Alternatively, you can try your request
216-
> again with a different VM hardware configuration or at a later
217-
> time.
218-
219-
- If the error resolution exceeds the number of characters supported in
220-
the problem description (`message` string of `google.rpc.Status`),
221-
or requires multiple troubleshooting steps, include the most
222-
common resolution in the message and use the `Help` payload to
223-
link to relevant documentation.
205+
a `Help` payload. See the [Help](#help) section for guidance.
224206

225207
#### Help payload
226208

0 commit comments

Comments
 (0)