error_details.proto 11 KB

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