This guide shows the intended protobuf shape for typed error payload messages that use trogon.error.v1alpha1.
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.
This is the protobuf projection of ADR 0129349218: Error Specification. The ADR explains the full boundary model; this guide only documents the descriptor fields that are safe to share.
import "trogon/error/v1alpha1/code.proto";
import "trogon/error/v1alpha1/options.proto";
import "trogon/error/v1alpha1/visibility.proto";
message ResourceAvailabilityError {
option (trogon.error.v1alpha1.message).template = {
domain: "compute.googleapis.com"
reason: "RESOURCE_AVAILABILITY"
message: "Requested resources are unavailable."
code: RESOURCE_EXHAUSTED
visibility: VISIBILITY_PUBLIC
help_links: [
{url: "https://docs.acme.com/compute", description: "Compute Docs"}
]
metadata: [
{key: "component", value: "compute", visibility: VISIBILITY_PUBLIC}
]
};
string zone = 1 [(trogon.error.v1alpha1.field).visibility = VISIBILITY_PUBLIC];
string vm_type = 2 [(trogon.error.v1alpha1.field).visibility = VISIBILITY_PUBLIC];
string service = 3 [(trogon.error.v1alpha1.field) = {
visibility: VISIBILITY_PUBLIC,
default_value: "compute-api"
}];
string region = 4 [(trogon.error.v1alpha1.field) = {
visibility: VISIBILITY_PUBLIC,
value: "us-east-1"
}];
}When a runtime emits this error, it should build the protocol-native error envelope from the template:
| Trogon option | Google RPC field |
|---|---|
code |
google.rpc.Status.code |
message |
google.rpc.Status.message |
domain |
google.rpc.ErrorInfo.domain |
reason |
google.rpc.ErrorInfo.reason |
metadata |
google.rpc.ErrorInfo.metadata |
| Payload fields | google.rpc.ErrorInfo.metadata using proto JSON names |
help_links |
google.rpc.Help.links |
For the example above, a runtime could emit this JSON representation of a google.rpc.Status:
{
"code": 8,
"message": "Requested resources are unavailable.",
"details": [
{
"@type": "type.googleapis.com/google.rpc.ErrorInfo",
"reason": "RESOURCE_AVAILABILITY",
"domain": "compute.googleapis.com",
"metadata": {
"component": "compute",
"region": "us-east-1",
"service": "compute-api",
"vmType": "n2-standard-16",
"zone": "us-east1-b"
}
},
{
"@type": "type.googleapis.com/google.rpc.Help",
"links": [
{
"description": "Compute Docs",
"url": "https://docs.acme.com/compute"
}
]
}
]
}templateis a message field, so it carries proto3 presence by default.- The template captures the parts of the Google RPC error contract that never vary at runtime:
domain,reason,code, defaultmessage, error-levelvisibility,help_links, and fixedmetadataentries. domainandreasondescribe thegoogle.rpc.ErrorInfoidentity for this error.reasonmust be stable within thedomain.metadatadeclares 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.- Payload fields hold the dynamic context for a single emission. Each field can carry
FieldOptions:visibilitycontrols who sees the field at runtime.VISIBILITY_UNSPECIFIEDis invalid for emitted metadata.value_policy.default_valuesubstitutes a value when the runtime field is empty.value_policy.valuepins the field to a contract-fixed value; the runtime payload is ignored on emit.
- Payload fields use their protobuf JSON names as
ErrorInfo.metadatakeys. For example,vm_typeemitsvmType. - Shared protos should use only
VISIBILITY_PUBLICandVISIBILITY_PRIVATE. Internal-only metadata belongs in runtime enrichment or internal overlays, not shared descriptors. visibilityis a Trogon filtering policy. It is not part ofgoogle.rpc.ErrorInfo.