Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
feat(types): update error_details.proto to a56cbf3b (#2286)
  • Loading branch information
kriswuollett committed Jun 20, 2025
commit 6c5627c9c49c6f429418e12451b8bc05894b7096
225 changes: 169 additions & 56 deletions tonic-types/proto/error_details.proto
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2020 Google LLC
// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -24,6 +24,58 @@ option java_outer_classname = "ErrorDetailsProto";
option java_package = "com.google.rpc";
option objc_class_prefix = "RPC";

// Describes the cause of the error with structured details.
//
// Example of an error when contacting the "pubsub.googleapis.com" API when it
// is not enabled:
//
// { "reason": "API_DISABLED"
// "domain": "googleapis.com"
// "metadata": {
// "resource": "projects/123",
// "service": "pubsub.googleapis.com"
// }
// }
//
// This response indicates that the pubsub.googleapis.com API is not enabled.
//
// Example of an error that is returned when attempting to create a Spanner
// instance in a region that is out of stock:
//
// { "reason": "STOCKOUT"
// "domain": "spanner.googleapis.com",
// "metadata": {
// "availableRegions": "us-central1,us-east2"
// }
// }
message ErrorInfo {
// The reason of the error. This is a constant value that identifies the
// proximate cause of the error. Error reasons are unique within a particular
// domain of errors. This should be at most 63 characters and match a
// regular expression of `[A-Z][A-Z0-9_]+[A-Z0-9]`, which represents
// UPPER_SNAKE_CASE.
string reason = 1;

// The logical grouping to which the "reason" belongs. The error domain
// is typically the registered service name of the tool or product that
// generates the error. Example: "pubsub.googleapis.com". If the error is
// generated by some common infrastructure, the error domain must be a
// globally unique value that identifies the infrastructure. For Google API
// infrastructure, the error domain is "googleapis.com".
string domain = 2;

// Additional structured details about this error.
//
// Keys must match a regular expression of `[a-z][a-zA-Z0-9-_]+` but should
// ideally be lowerCamelCase. Also, they must be limited to 64 characters in
// length. When identifying the current value of an exceeded limit, the units
// should be contained in the key, not the value. For example, rather than
// `{"instanceLimit": "100/request"}`, should be returned as,
// `{"instanceLimitPerRequest": "100"}`, if the client exceeds the number of
// instances that can be created in a single (batch) request.
map<string, string> metadata = 3;
}

// Describes when the clients can retry a failed request. Clients could ignore
// the recommendation here or retry when this information is missing from error
// responses.
Expand Down Expand Up @@ -79,61 +131,75 @@ message QuotaFailure {
// For example: "Service disabled" or "Daily Limit for read operations
// exceeded".
string description = 2;
}

// Describes all quota violations.
repeated Violation violations = 1;
}
// The API Service from which the `QuotaFailure.Violation` orginates. In
// some cases, Quota issues originate from an API Service other than the one
// that was called. In other words, a dependency of the called API Service
// could be the cause of the `QuotaFailure`, and this field would have the
// dependency API service name.
//
// For example, if the called API is Kubernetes Engine API
// (container.googleapis.com), and a quota violation occurs in the
// Kubernetes Engine API itself, this field would be
// "container.googleapis.com". On the other hand, if the quota violation
// occurs when the Kubernetes Engine API creates VMs in the Compute Engine
// API (compute.googleapis.com), this field would be
// "compute.googleapis.com".
string api_service = 3;

// Describes the cause of the error with structured details.
//
// Example of an error when contacting the "pubsub.googleapis.com" API when it
// is not enabled:
// ```json
// { "reason": "API_DISABLED"
// "domain": "googleapis.com"
// "metadata": {
// "resource": "projects/123",
// "service": "pubsub.googleapis.com"
// }
// }
// ```
// This response indicates that the pubsub.googleapis.com API is not enabled.
//
// Example of an error that is returned when attempting to create a Spanner
// instance in a region that is out of stock:
// ```json
// { "reason": "STOCKOUT"
// "domain": "spanner.googleapis.com",
// "metadata": {
// "availableRegions": "us-central1,us-east2"
// }
// }
// ```
message ErrorInfo {
// The reason of the error. This is a constant value that identifies the
// proximate cause of the error. Error reasons are unique within a particular
// domain of errors. This should be at most 63 characters and match
// /[A-Z0-9_]+/.
string reason = 1;
// The metric of the violated quota. A quota metric is a named counter to
// measure usage, such as API requests or CPUs. When an activity occurs in a
// service, such as Virtual Machine allocation, one or more quota metrics
// may be affected.
//
// For example, "compute.googleapis.com/cpus_per_vm_family",
// "storage.googleapis.com/internet_egress_bandwidth".
string quota_metric = 4;

// The logical grouping to which the "reason" belongs. The error domain
// is typically the registered service name of the tool or product that
// generates the error. Example: "pubsub.googleapis.com". If the error is
// generated by some common infrastructure, the error domain must be a
// globally unique value that identifies the infrastructure. For Google API
// infrastructure, the error domain is "googleapis.com".
string domain = 2;
// The id of the violated quota. Also know as "limit name", this is the
// unique identifier of a quota in the context of an API service.
//
// For example, "CPUS-PER-VM-FAMILY-per-project-region".
string quota_id = 5;

// Additional structured details about this error.
//
// Keys should match /[a-zA-Z0-9-_]/ and be limited to 64 characters in
// length. When identifying the current value of an exceeded limit, the units
// should be contained in the key, not the value. For example, rather than
// {"instanceLimit": "100/request"}, should be returned as,
// {"instanceLimitPerRequest": "100"}, if the client exceeds the number of
// instances that can be created in a single (batch) request.
map<string, string> metadata = 3;
// The dimensions of the violated quota. Every non-global quota is enforced
// on a set of dimensions. While quota metric defines what to count, the
// dimensions specify for what aspects the counter should be increased.
//
// For example, the quota "CPUs per region per VM family" enforces a limit
// on the metric "compute.googleapis.com/cpus_per_vm_family" on dimensions
// "region" and "vm_family". And if the violation occurred in region
// "us-central1" and for VM family "n1", the quota_dimensions would be,
//
// {
// "region": "us-central1",
// "vm_family": "n1",
// }
//
// When a quota is enforced globally, the quota_dimensions would always be
// empty.
map<string, string> quota_dimensions = 6;

// The enforced quota value at the time of the `QuotaFailure`.
//
// For example, if the enforced quota value at the time of the
// `QuotaFailure` on the number of CPUs is "10", then the value of this
// field would reflect this quantity.
int64 quota_value = 7;

// The new quota value being rolled out at the time of the violation. At the
// completion of the rollout, this value will be enforced in place of
// quota_value. If no rollout is in progress at the time of the violation,
// this field is not set.
//
// For example, if at the time of the violation a rollout is in progress
// changing the number of CPUs quota from 10 to 20, 20 would be the value of
// this field.
optional int64 future_quota_value = 8;
}

// Describes all quota violations.
repeated Violation violations = 1;
}

// Describes what preconditions have failed.
Expand Down Expand Up @@ -170,13 +236,59 @@ message PreconditionFailure {
message BadRequest {
// A message type used to describe a single bad request field.
message FieldViolation {
// A path leading to a field in the request body. The value will be a
// A path that leads to a field in the request body. The value will be a
// sequence of dot-separated identifiers that identify a protocol buffer
// field. E.g., "field_violations.field" would identify this field.
// field.
//
// Consider the following:
//
// message CreateContactRequest {
// message EmailAddress {
// enum Type {
// TYPE_UNSPECIFIED = 0;
// HOME = 1;
// WORK = 2;
// }
//
// optional string email = 1;
// repeated EmailType type = 2;
// }
//
// string full_name = 1;
// repeated EmailAddress email_addresses = 2;
// }
//
// In this example, in proto `field` could take one of the following values:
//
// * `full_name` for a violation in the `full_name` value
// * `email_addresses[1].email` for a violation in the `email` field of the
// first `email_addresses` message
// * `email_addresses[3].type[2]` for a violation in the second `type`
// value in the third `email_addresses` message.
//
// In JSON, the same values are represented as:
//
// * `fullName` for a violation in the `fullName` value
// * `emailAddresses[1].email` for a violation in the `email` field of the
// first `emailAddresses` message
// * `emailAddresses[3].type[2]` for a violation in the second `type`
// value in the third `emailAddresses` message.
string field = 1;

// A description of why the request element is bad.
string description = 2;

// The reason of the field-level error. This is a constant value that
// identifies the proximate cause of the field-level error. It should
// uniquely identify the type of the FieldViolation within the scope of the
// google.rpc.ErrorInfo.domain. This should be at most 63
// characters and match a regular expression of `[A-Z][A-Z0-9_]+[A-Z0-9]`,
// which represents UPPER_SNAKE_CASE.
string reason = 3;

// Provides a localized error message for field-level errors that is safe to
// return to the API consumer.
LocalizedMessage localized_message = 4;
}

// Describes all violations in a client request.
Expand Down Expand Up @@ -204,7 +316,8 @@ message ResourceInfo {

// The name of the resource being accessed. For example, a shared calendar
// name: "example.com_4fghdhgsrgh@group.calendar.google.com", if the current
// error is [google.rpc.Code.PERMISSION_DENIED][google.rpc.Code.PERMISSION_DENIED].
// error is
// [google.rpc.Code.PERMISSION_DENIED][google.rpc.Code.PERMISSION_DENIED].
string resource_name = 2;

// The owner of the resource (optional).
Expand Down Expand Up @@ -241,7 +354,7 @@ message Help {
// which can be attached to an RPC error.
message LocalizedMessage {
// The locale used following the specification defined at
// http://www.rfc-editor.org/rfc/bcp/bcp47.txt.
// https://www.rfc-editor.org/rfc/bcp/bcp47.txt.
// Examples are: "en-US", "fr-CH", "es-MX"
string locale = 1;

Expand Down
Loading