You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Trogon error options describe the Google RPC rich error details a runtime should emit. They are descriptor metadata, not a replacement for gRPC, Connect, or HTTP error envelopes.
4
+
5
+
## Why This Exists
6
+
7
+
Without a shared proto annotation, every runtime has to construct `google.rpc.Status`, `google.rpc.ErrorInfo`, and related details by hand. That makes stable fields such as `domain`, `reason`, and metadata keys easy to drift across languages.
8
+
9
+
The `trogon.error.v1alpha1` package keeps that contract close to the typed error payload message. Code generators and runtime adapters can read the same descriptor metadata and produce consistent Google RPC details.
10
+
11
+
## Mapping
12
+
13
+
| Trogon template field | Google RPC target |
14
+
|-----------------------|-------------------|
15
+
|`code`|`google.rpc.Status.code`|
16
+
|`message`|`google.rpc.Status.message`|
17
+
|`domain`|`google.rpc.ErrorInfo.domain`|
18
+
|`reason`|`google.rpc.ErrorInfo.reason`|
19
+
|`metadata`|`google.rpc.ErrorInfo.metadata`|
20
+
|`help_links`|`google.rpc.Help.links`|
21
+
22
+
Payload fields annotated with `trogon.error.v1alpha1.field` supply emission-specific `ErrorInfo.metadata` values. Template metadata supplies fixed metadata values that apply to every emission. Metadata keys should use lowerCamelCase; payload fields use their protobuf JSON names.
23
+
24
+
## Boundaries
25
+
26
+
Trogon error templates do not declare which RPC can return an error. That belongs in a method-level outcome option.
27
+
28
+
Trogon error templates also do not model successful outcomes. `trogon.error.v1alpha1.Code` intentionally mirrors only Google RPC error codes and omits `OK`.
29
+
30
+
Shared error protos should expose only public or private metadata. Internal-only metadata belongs in runtime enrichment, observability pipelines, or internal-only overlays because descriptor annotations are visible to anyone who receives the proto.
31
+
32
+
The runtime owns protocol adaptation. A gRPC runtime can emit `google.rpc.Status` with typed details. A Connect runtime can expose the same semantics through Connect errors and strongly typed details.
Copy file name to clipboardExpand all lines: docs/how-to/document-errors-in-proto.md
+60-7Lines changed: 60 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,8 @@
2
2
3
3
This guide shows the intended protobuf shape for typed error payload messages that use `trogon.error.v1alpha1`.
4
4
5
+
Trogon error annotations are descriptor-time templates for the Google RPC rich error model. They describe the `google.rpc.Status` and `google.rpc.ErrorInfo` details a runtime should emit when the typed error occurs.
-`template` is a message field, so it carries proto3 presence by default.
44
-
- The template captures the parts of the error contract that never vary at runtime: `domain`, `reason`, `code`, default `message`, error-level `visibility`, `help_links`, and fixed `metadata` entries.
45
-
-`metadata` declares contract-level constants (component, team, subsystem) that attach to every emission without occupying a wire field. Keys must be unique within the template and must not collide with field names on the payload message.
91
+
- The template captures the parts of the Google RPC error contract that never vary at runtime: `domain`, `reason`, `code`, default `message`, error-level `visibility`, `help_links`, and fixed `metadata` entries.
92
+
-`domain` and `reason` describe the `google.rpc.ErrorInfo` identity for this error. `reason` must be stable within the `domain`.
93
+
-`metadata` declares contract-level constants (component, product, support category) that attach to every emission without occupying a wire field. Keys should use lowerCamelCase, must be unique within the template, and must not collide with field names on the payload message.
46
94
- Payload fields hold the dynamic context for a single emission. Each field can carry `FieldOptions`:
47
-
-`visibility` controls who sees the field at runtime (defaults to `INTERNAL`).
95
+
-`visibility` controls who sees the field at runtime. `VISIBILITY_UNSPECIFIED` is invalid for emitted metadata.
48
96
-`value_policy.default_value` substitutes a value when the runtime field is empty.
49
97
-`value_policy.value` pins the field to a contract-fixed value; the runtime payload is ignored on emit.
98
+
- Payload fields use their protobuf JSON names as `ErrorInfo.metadata` keys. For example, `vm_type` emits `vmType`.
99
+
- Shared protos should use only `VISIBILITY_PUBLIC` and `VISIBILITY_PRIVATE`. Internal-only metadata belongs in runtime enrichment or internal overlays, not shared descriptors.
100
+
-`visibility` is a Trogon filtering policy. It is not part of `google.rpc.ErrorInfo`.
0 commit comments