xref: /aosp_15_r20/external/googleapis/google/rpc/error_details.proto (revision d5c09012810ac0c9f33fe448fb6da8260d444cc9)
1*d5c09012SAndroid Build Coastguard Worker// Copyright 2022 Google LLC
2*d5c09012SAndroid Build Coastguard Worker//
3*d5c09012SAndroid Build Coastguard Worker// Licensed under the Apache License, Version 2.0 (the "License");
4*d5c09012SAndroid Build Coastguard Worker// you may not use this file except in compliance with the License.
5*d5c09012SAndroid Build Coastguard Worker// You may obtain a copy of the License at
6*d5c09012SAndroid Build Coastguard Worker//
7*d5c09012SAndroid Build Coastguard Worker//     http://www.apache.org/licenses/LICENSE-2.0
8*d5c09012SAndroid Build Coastguard Worker//
9*d5c09012SAndroid Build Coastguard Worker// Unless required by applicable law or agreed to in writing, software
10*d5c09012SAndroid Build Coastguard Worker// distributed under the License is distributed on an "AS IS" BASIS,
11*d5c09012SAndroid Build Coastguard Worker// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12*d5c09012SAndroid Build Coastguard Worker// See the License for the specific language governing permissions and
13*d5c09012SAndroid Build Coastguard Worker// limitations under the License.
14*d5c09012SAndroid Build Coastguard Worker
15*d5c09012SAndroid Build Coastguard Workersyntax = "proto3";
16*d5c09012SAndroid Build Coastguard Worker
17*d5c09012SAndroid Build Coastguard Workerpackage google.rpc;
18*d5c09012SAndroid Build Coastguard Worker
19*d5c09012SAndroid Build Coastguard Workerimport "google/protobuf/duration.proto";
20*d5c09012SAndroid Build Coastguard Worker
21*d5c09012SAndroid Build Coastguard Workeroption go_package = "google.golang.org/genproto/googleapis/rpc/errdetails;errdetails";
22*d5c09012SAndroid Build Coastguard Workeroption java_multiple_files = true;
23*d5c09012SAndroid Build Coastguard Workeroption java_outer_classname = "ErrorDetailsProto";
24*d5c09012SAndroid Build Coastguard Workeroption java_package = "com.google.rpc";
25*d5c09012SAndroid Build Coastguard Workeroption objc_class_prefix = "RPC";
26*d5c09012SAndroid Build Coastguard Worker
27*d5c09012SAndroid Build Coastguard Worker// Describes the cause of the error with structured details.
28*d5c09012SAndroid Build Coastguard Worker//
29*d5c09012SAndroid Build Coastguard Worker// Example of an error when contacting the "pubsub.googleapis.com" API when it
30*d5c09012SAndroid Build Coastguard Worker// is not enabled:
31*d5c09012SAndroid Build Coastguard Worker//
32*d5c09012SAndroid Build Coastguard Worker//     { "reason": "API_DISABLED"
33*d5c09012SAndroid Build Coastguard Worker//       "domain": "googleapis.com"
34*d5c09012SAndroid Build Coastguard Worker//       "metadata": {
35*d5c09012SAndroid Build Coastguard Worker//         "resource": "projects/123",
36*d5c09012SAndroid Build Coastguard Worker//         "service": "pubsub.googleapis.com"
37*d5c09012SAndroid Build Coastguard Worker//       }
38*d5c09012SAndroid Build Coastguard Worker//     }
39*d5c09012SAndroid Build Coastguard Worker//
40*d5c09012SAndroid Build Coastguard Worker// This response indicates that the pubsub.googleapis.com API is not enabled.
41*d5c09012SAndroid Build Coastguard Worker//
42*d5c09012SAndroid Build Coastguard Worker// Example of an error that is returned when attempting to create a Spanner
43*d5c09012SAndroid Build Coastguard Worker// instance in a region that is out of stock:
44*d5c09012SAndroid Build Coastguard Worker//
45*d5c09012SAndroid Build Coastguard Worker//     { "reason": "STOCKOUT"
46*d5c09012SAndroid Build Coastguard Worker//       "domain": "spanner.googleapis.com",
47*d5c09012SAndroid Build Coastguard Worker//       "metadata": {
48*d5c09012SAndroid Build Coastguard Worker//         "availableRegions": "us-central1,us-east2"
49*d5c09012SAndroid Build Coastguard Worker//       }
50*d5c09012SAndroid Build Coastguard Worker//     }
51*d5c09012SAndroid Build Coastguard Workermessage ErrorInfo {
52*d5c09012SAndroid Build Coastguard Worker  // The reason of the error. This is a constant value that identifies the
53*d5c09012SAndroid Build Coastguard Worker  // proximate cause of the error. Error reasons are unique within a particular
54*d5c09012SAndroid Build Coastguard Worker  // domain of errors. This should be at most 63 characters and match a
55*d5c09012SAndroid Build Coastguard Worker  // regular expression of `[A-Z][A-Z0-9_]+[A-Z0-9]`, which represents
56*d5c09012SAndroid Build Coastguard Worker  // UPPER_SNAKE_CASE.
57*d5c09012SAndroid Build Coastguard Worker  string reason = 1;
58*d5c09012SAndroid Build Coastguard Worker
59*d5c09012SAndroid Build Coastguard Worker  // The logical grouping to which the "reason" belongs. The error domain
60*d5c09012SAndroid Build Coastguard Worker  // is typically the registered service name of the tool or product that
61*d5c09012SAndroid Build Coastguard Worker  // generates the error. Example: "pubsub.googleapis.com". If the error is
62*d5c09012SAndroid Build Coastguard Worker  // generated by some common infrastructure, the error domain must be a
63*d5c09012SAndroid Build Coastguard Worker  // globally unique value that identifies the infrastructure. For Google API
64*d5c09012SAndroid Build Coastguard Worker  // infrastructure, the error domain is "googleapis.com".
65*d5c09012SAndroid Build Coastguard Worker  string domain = 2;
66*d5c09012SAndroid Build Coastguard Worker
67*d5c09012SAndroid Build Coastguard Worker  // Additional structured details about this error.
68*d5c09012SAndroid Build Coastguard Worker  //
69*d5c09012SAndroid Build Coastguard Worker  // Keys should match /[a-zA-Z0-9-_]/ and be limited to 64 characters in
70*d5c09012SAndroid Build Coastguard Worker  // length. When identifying the current value of an exceeded limit, the units
71*d5c09012SAndroid Build Coastguard Worker  // should be contained in the key, not the value.  For example, rather than
72*d5c09012SAndroid Build Coastguard Worker  // {"instanceLimit": "100/request"}, should be returned as,
73*d5c09012SAndroid Build Coastguard Worker  // {"instanceLimitPerRequest": "100"}, if the client exceeds the number of
74*d5c09012SAndroid Build Coastguard Worker  // instances that can be created in a single (batch) request.
75*d5c09012SAndroid Build Coastguard Worker  map<string, string> metadata = 3;
76*d5c09012SAndroid Build Coastguard Worker}
77*d5c09012SAndroid Build Coastguard Worker
78*d5c09012SAndroid Build Coastguard Worker// Describes when the clients can retry a failed request. Clients could ignore
79*d5c09012SAndroid Build Coastguard Worker// the recommendation here or retry when this information is missing from error
80*d5c09012SAndroid Build Coastguard Worker// responses.
81*d5c09012SAndroid Build Coastguard Worker//
82*d5c09012SAndroid Build Coastguard Worker// It's always recommended that clients should use exponential backoff when
83*d5c09012SAndroid Build Coastguard Worker// retrying.
84*d5c09012SAndroid Build Coastguard Worker//
85*d5c09012SAndroid Build Coastguard Worker// Clients should wait until `retry_delay` amount of time has passed since
86*d5c09012SAndroid Build Coastguard Worker// receiving the error response before retrying.  If retrying requests also
87*d5c09012SAndroid Build Coastguard Worker// fail, clients should use an exponential backoff scheme to gradually increase
88*d5c09012SAndroid Build Coastguard Worker// the delay between retries based on `retry_delay`, until either a maximum
89*d5c09012SAndroid Build Coastguard Worker// number of retries have been reached or a maximum retry delay cap has been
90*d5c09012SAndroid Build Coastguard Worker// reached.
91*d5c09012SAndroid Build Coastguard Workermessage RetryInfo {
92*d5c09012SAndroid Build Coastguard Worker  // Clients should wait at least this long between retrying the same request.
93*d5c09012SAndroid Build Coastguard Worker  google.protobuf.Duration retry_delay = 1;
94*d5c09012SAndroid Build Coastguard Worker}
95*d5c09012SAndroid Build Coastguard Worker
96*d5c09012SAndroid Build Coastguard Worker// Describes additional debugging info.
97*d5c09012SAndroid Build Coastguard Workermessage DebugInfo {
98*d5c09012SAndroid Build Coastguard Worker  // The stack trace entries indicating where the error occurred.
99*d5c09012SAndroid Build Coastguard Worker  repeated string stack_entries = 1;
100*d5c09012SAndroid Build Coastguard Worker
101*d5c09012SAndroid Build Coastguard Worker  // Additional debugging information provided by the server.
102*d5c09012SAndroid Build Coastguard Worker  string detail = 2;
103*d5c09012SAndroid Build Coastguard Worker}
104*d5c09012SAndroid Build Coastguard Worker
105*d5c09012SAndroid Build Coastguard Worker// Describes how a quota check failed.
106*d5c09012SAndroid Build Coastguard Worker//
107*d5c09012SAndroid Build Coastguard Worker// For example if a daily limit was exceeded for the calling project,
108*d5c09012SAndroid Build Coastguard Worker// a service could respond with a QuotaFailure detail containing the project
109*d5c09012SAndroid Build Coastguard Worker// id and the description of the quota limit that was exceeded.  If the
110*d5c09012SAndroid Build Coastguard Worker// calling project hasn't enabled the service in the developer console, then
111*d5c09012SAndroid Build Coastguard Worker// a service could respond with the project id and set `service_disabled`
112*d5c09012SAndroid Build Coastguard Worker// to true.
113*d5c09012SAndroid Build Coastguard Worker//
114*d5c09012SAndroid Build Coastguard Worker// Also see RetryInfo and Help types for other details about handling a
115*d5c09012SAndroid Build Coastguard Worker// quota failure.
116*d5c09012SAndroid Build Coastguard Workermessage QuotaFailure {
117*d5c09012SAndroid Build Coastguard Worker  // A message type used to describe a single quota violation.  For example, a
118*d5c09012SAndroid Build Coastguard Worker  // daily quota or a custom quota that was exceeded.
119*d5c09012SAndroid Build Coastguard Worker  message Violation {
120*d5c09012SAndroid Build Coastguard Worker    // The subject on which the quota check failed.
121*d5c09012SAndroid Build Coastguard Worker    // For example, "clientip:<ip address of client>" or "project:<Google
122*d5c09012SAndroid Build Coastguard Worker    // developer project id>".
123*d5c09012SAndroid Build Coastguard Worker    string subject = 1;
124*d5c09012SAndroid Build Coastguard Worker
125*d5c09012SAndroid Build Coastguard Worker    // A description of how the quota check failed. Clients can use this
126*d5c09012SAndroid Build Coastguard Worker    // description to find more about the quota configuration in the service's
127*d5c09012SAndroid Build Coastguard Worker    // public documentation, or find the relevant quota limit to adjust through
128*d5c09012SAndroid Build Coastguard Worker    // developer console.
129*d5c09012SAndroid Build Coastguard Worker    //
130*d5c09012SAndroid Build Coastguard Worker    // For example: "Service disabled" or "Daily Limit for read operations
131*d5c09012SAndroid Build Coastguard Worker    // exceeded".
132*d5c09012SAndroid Build Coastguard Worker    string description = 2;
133*d5c09012SAndroid Build Coastguard Worker  }
134*d5c09012SAndroid Build Coastguard Worker
135*d5c09012SAndroid Build Coastguard Worker  // Describes all quota violations.
136*d5c09012SAndroid Build Coastguard Worker  repeated Violation violations = 1;
137*d5c09012SAndroid Build Coastguard Worker}
138*d5c09012SAndroid Build Coastguard Worker
139*d5c09012SAndroid Build Coastguard Worker// Describes what preconditions have failed.
140*d5c09012SAndroid Build Coastguard Worker//
141*d5c09012SAndroid Build Coastguard Worker// For example, if an RPC failed because it required the Terms of Service to be
142*d5c09012SAndroid Build Coastguard Worker// acknowledged, it could list the terms of service violation in the
143*d5c09012SAndroid Build Coastguard Worker// PreconditionFailure message.
144*d5c09012SAndroid Build Coastguard Workermessage PreconditionFailure {
145*d5c09012SAndroid Build Coastguard Worker  // A message type used to describe a single precondition failure.
146*d5c09012SAndroid Build Coastguard Worker  message Violation {
147*d5c09012SAndroid Build Coastguard Worker    // The type of PreconditionFailure. We recommend using a service-specific
148*d5c09012SAndroid Build Coastguard Worker    // enum type to define the supported precondition violation subjects. For
149*d5c09012SAndroid Build Coastguard Worker    // example, "TOS" for "Terms of Service violation".
150*d5c09012SAndroid Build Coastguard Worker    string type = 1;
151*d5c09012SAndroid Build Coastguard Worker
152*d5c09012SAndroid Build Coastguard Worker    // The subject, relative to the type, that failed.
153*d5c09012SAndroid Build Coastguard Worker    // For example, "google.com/cloud" relative to the "TOS" type would indicate
154*d5c09012SAndroid Build Coastguard Worker    // which terms of service is being referenced.
155*d5c09012SAndroid Build Coastguard Worker    string subject = 2;
156*d5c09012SAndroid Build Coastguard Worker
157*d5c09012SAndroid Build Coastguard Worker    // A description of how the precondition failed. Developers can use this
158*d5c09012SAndroid Build Coastguard Worker    // description to understand how to fix the failure.
159*d5c09012SAndroid Build Coastguard Worker    //
160*d5c09012SAndroid Build Coastguard Worker    // For example: "Terms of service not accepted".
161*d5c09012SAndroid Build Coastguard Worker    string description = 3;
162*d5c09012SAndroid Build Coastguard Worker  }
163*d5c09012SAndroid Build Coastguard Worker
164*d5c09012SAndroid Build Coastguard Worker  // Describes all precondition violations.
165*d5c09012SAndroid Build Coastguard Worker  repeated Violation violations = 1;
166*d5c09012SAndroid Build Coastguard Worker}
167*d5c09012SAndroid Build Coastguard Worker
168*d5c09012SAndroid Build Coastguard Worker// Describes violations in a client request. This error type focuses on the
169*d5c09012SAndroid Build Coastguard Worker// syntactic aspects of the request.
170*d5c09012SAndroid Build Coastguard Workermessage BadRequest {
171*d5c09012SAndroid Build Coastguard Worker  // A message type used to describe a single bad request field.
172*d5c09012SAndroid Build Coastguard Worker  message FieldViolation {
173*d5c09012SAndroid Build Coastguard Worker    // A path that leads to a field in the request body. The value will be a
174*d5c09012SAndroid Build Coastguard Worker    // sequence of dot-separated identifiers that identify a protocol buffer
175*d5c09012SAndroid Build Coastguard Worker    // field.
176*d5c09012SAndroid Build Coastguard Worker    //
177*d5c09012SAndroid Build Coastguard Worker    // Consider the following:
178*d5c09012SAndroid Build Coastguard Worker    //
179*d5c09012SAndroid Build Coastguard Worker    //     message CreateContactRequest {
180*d5c09012SAndroid Build Coastguard Worker    //       message EmailAddress {
181*d5c09012SAndroid Build Coastguard Worker    //         enum Type {
182*d5c09012SAndroid Build Coastguard Worker    //           TYPE_UNSPECIFIED = 0;
183*d5c09012SAndroid Build Coastguard Worker    //           HOME = 1;
184*d5c09012SAndroid Build Coastguard Worker    //           WORK = 2;
185*d5c09012SAndroid Build Coastguard Worker    //         }
186*d5c09012SAndroid Build Coastguard Worker    //
187*d5c09012SAndroid Build Coastguard Worker    //         optional string email = 1;
188*d5c09012SAndroid Build Coastguard Worker    //         repeated EmailType type = 2;
189*d5c09012SAndroid Build Coastguard Worker    //       }
190*d5c09012SAndroid Build Coastguard Worker    //
191*d5c09012SAndroid Build Coastguard Worker    //       string full_name = 1;
192*d5c09012SAndroid Build Coastguard Worker    //       repeated EmailAddress email_addresses = 2;
193*d5c09012SAndroid Build Coastguard Worker    //     }
194*d5c09012SAndroid Build Coastguard Worker    //
195*d5c09012SAndroid Build Coastguard Worker    // In this example, in proto `field` could take one of the following values:
196*d5c09012SAndroid Build Coastguard Worker    //
197*d5c09012SAndroid Build Coastguard Worker    // * `full_name` for a violation in the `full_name` value
198*d5c09012SAndroid Build Coastguard Worker    // * `email_addresses[1].email` for a violation in the `email` field of the
199*d5c09012SAndroid Build Coastguard Worker    //   first `email_addresses` message
200*d5c09012SAndroid Build Coastguard Worker    // * `email_addresses[3].type[2]` for a violation in the second `type`
201*d5c09012SAndroid Build Coastguard Worker    //   value in the third `email_addresses` message.
202*d5c09012SAndroid Build Coastguard Worker    //
203*d5c09012SAndroid Build Coastguard Worker    // In JSON, the same values are represented as:
204*d5c09012SAndroid Build Coastguard Worker    //
205*d5c09012SAndroid Build Coastguard Worker    // * `fullName` for a violation in the `fullName` value
206*d5c09012SAndroid Build Coastguard Worker    // * `emailAddresses[1].email` for a violation in the `email` field of the
207*d5c09012SAndroid Build Coastguard Worker    //   first `emailAddresses` message
208*d5c09012SAndroid Build Coastguard Worker    // * `emailAddresses[3].type[2]` for a violation in the second `type`
209*d5c09012SAndroid Build Coastguard Worker    //   value in the third `emailAddresses` message.
210*d5c09012SAndroid Build Coastguard Worker    string field = 1;
211*d5c09012SAndroid Build Coastguard Worker
212*d5c09012SAndroid Build Coastguard Worker    // A description of why the request element is bad.
213*d5c09012SAndroid Build Coastguard Worker    string description = 2;
214*d5c09012SAndroid Build Coastguard Worker  }
215*d5c09012SAndroid Build Coastguard Worker
216*d5c09012SAndroid Build Coastguard Worker  // Describes all violations in a client request.
217*d5c09012SAndroid Build Coastguard Worker  repeated FieldViolation field_violations = 1;
218*d5c09012SAndroid Build Coastguard Worker}
219*d5c09012SAndroid Build Coastguard Worker
220*d5c09012SAndroid Build Coastguard Worker// Contains metadata about the request that clients can attach when filing a bug
221*d5c09012SAndroid Build Coastguard Worker// or providing other forms of feedback.
222*d5c09012SAndroid Build Coastguard Workermessage RequestInfo {
223*d5c09012SAndroid Build Coastguard Worker  // An opaque string that should only be interpreted by the service generating
224*d5c09012SAndroid Build Coastguard Worker  // it. For example, it can be used to identify requests in the service's logs.
225*d5c09012SAndroid Build Coastguard Worker  string request_id = 1;
226*d5c09012SAndroid Build Coastguard Worker
227*d5c09012SAndroid Build Coastguard Worker  // Any data that was used to serve this request. For example, an encrypted
228*d5c09012SAndroid Build Coastguard Worker  // stack trace that can be sent back to the service provider for debugging.
229*d5c09012SAndroid Build Coastguard Worker  string serving_data = 2;
230*d5c09012SAndroid Build Coastguard Worker}
231*d5c09012SAndroid Build Coastguard Worker
232*d5c09012SAndroid Build Coastguard Worker// Describes the resource that is being accessed.
233*d5c09012SAndroid Build Coastguard Workermessage ResourceInfo {
234*d5c09012SAndroid Build Coastguard Worker  // A name for the type of resource being accessed, e.g. "sql table",
235*d5c09012SAndroid Build Coastguard Worker  // "cloud storage bucket", "file", "Google calendar"; or the type URL
236*d5c09012SAndroid Build Coastguard Worker  // of the resource: e.g. "type.googleapis.com/google.pubsub.v1.Topic".
237*d5c09012SAndroid Build Coastguard Worker  string resource_type = 1;
238*d5c09012SAndroid Build Coastguard Worker
239*d5c09012SAndroid Build Coastguard Worker  // The name of the resource being accessed.  For example, a shared calendar
240*d5c09012SAndroid Build Coastguard Worker  // name: "[email protected]", if the current
241*d5c09012SAndroid Build Coastguard Worker  // error is
242*d5c09012SAndroid Build Coastguard Worker  // [google.rpc.Code.PERMISSION_DENIED][google.rpc.Code.PERMISSION_DENIED].
243*d5c09012SAndroid Build Coastguard Worker  string resource_name = 2;
244*d5c09012SAndroid Build Coastguard Worker
245*d5c09012SAndroid Build Coastguard Worker  // The owner of the resource (optional).
246*d5c09012SAndroid Build Coastguard Worker  // For example, "user:<owner email>" or "project:<Google developer project
247*d5c09012SAndroid Build Coastguard Worker  // id>".
248*d5c09012SAndroid Build Coastguard Worker  string owner = 3;
249*d5c09012SAndroid Build Coastguard Worker
250*d5c09012SAndroid Build Coastguard Worker  // Describes what error is encountered when accessing this resource.
251*d5c09012SAndroid Build Coastguard Worker  // For example, updating a cloud project may require the `writer` permission
252*d5c09012SAndroid Build Coastguard Worker  // on the developer console project.
253*d5c09012SAndroid Build Coastguard Worker  string description = 4;
254*d5c09012SAndroid Build Coastguard Worker}
255*d5c09012SAndroid Build Coastguard Worker
256*d5c09012SAndroid Build Coastguard Worker// Provides links to documentation or for performing an out of band action.
257*d5c09012SAndroid Build Coastguard Worker//
258*d5c09012SAndroid Build Coastguard Worker// For example, if a quota check failed with an error indicating the calling
259*d5c09012SAndroid Build Coastguard Worker// project hasn't enabled the accessed service, this can contain a URL pointing
260*d5c09012SAndroid Build Coastguard Worker// directly to the right place in the developer console to flip the bit.
261*d5c09012SAndroid Build Coastguard Workermessage Help {
262*d5c09012SAndroid Build Coastguard Worker  // Describes a URL link.
263*d5c09012SAndroid Build Coastguard Worker  message Link {
264*d5c09012SAndroid Build Coastguard Worker    // Describes what the link offers.
265*d5c09012SAndroid Build Coastguard Worker    string description = 1;
266*d5c09012SAndroid Build Coastguard Worker
267*d5c09012SAndroid Build Coastguard Worker    // The URL of the link.
268*d5c09012SAndroid Build Coastguard Worker    string url = 2;
269*d5c09012SAndroid Build Coastguard Worker  }
270*d5c09012SAndroid Build Coastguard Worker
271*d5c09012SAndroid Build Coastguard Worker  // URL(s) pointing to additional information on handling the current error.
272*d5c09012SAndroid Build Coastguard Worker  repeated Link links = 1;
273*d5c09012SAndroid Build Coastguard Worker}
274*d5c09012SAndroid Build Coastguard Worker
275*d5c09012SAndroid Build Coastguard Worker// Provides a localized error message that is safe to return to the user
276*d5c09012SAndroid Build Coastguard Worker// which can be attached to an RPC error.
277*d5c09012SAndroid Build Coastguard Workermessage LocalizedMessage {
278*d5c09012SAndroid Build Coastguard Worker  // The locale used following the specification defined at
279*d5c09012SAndroid Build Coastguard Worker  // https://www.rfc-editor.org/rfc/bcp/bcp47.txt.
280*d5c09012SAndroid Build Coastguard Worker  // Examples are: "en-US", "fr-CH", "es-MX"
281*d5c09012SAndroid Build Coastguard Worker  string locale = 1;
282*d5c09012SAndroid Build Coastguard Worker
283*d5c09012SAndroid Build Coastguard Worker  // The localized error message in the above locale.
284*d5c09012SAndroid Build Coastguard Worker  string message = 2;
285*d5c09012SAndroid Build Coastguard Worker}
286