Errors and reasons
An HTTP/JSON error is an Error carrying an ErrorInfo. Branch on its reason, not the message.
A failed request returns an HTTP status and a JSON Error, in the shape of google.rpc.Status.
Its details carry an ErrorInfo (a google.rpc.ErrorInfo) whose reason says why the request failed:
{
"code": 5,
"message": "not_found",
"details": [
{
"@type": "type.googleapis.com/google.rpc.ErrorInfo",
"reason": "PRODUCT_NOT_FOUND",
"domain": "drophawk.net"
}
]
}codeis the gRPC status code that matches the HTTP status (5isNOT_FOUND).messageis the code's name, such asnot_found: stable, for logs, and not for display.detailsholds anErrorInfo, whose@typeistype.googleapis.com/google.rpc.ErrorInfoand whosedomainisdrophawk.net. Itsreasonis what to branch on: one HTTP status can be shared by several causes. Some reasons add context inmetadata, as string values.
details is a list of typed entries: an ErrorInfo, or an ErrorDetail of a type you do not know yet, and more may be added within v1.
Find the entry whose @type is type.googleapis.com/google.rpc.ErrorInfo, and skip any entry whose @type you do not recognise.
Every HTTP/JSON error carries that ErrorInfo.
If a response ever arrives without one, or with a reason you do not recognise, decide what to do from the HTTP status alone.
Reasons
| HTTP | Reason | Meaning |
|---|---|---|
| 404 | PRODUCT_NOT_FOUND | No Product is known by the identifier, or it has been removed from the catalog. |
| 400 | INVALID_IDENTIFIER | The identifier cannot name any Product. |
| 400 | INVALID_QUERY | The search query q is blank, over 256 bytes, or has control characters. |
| 400 | INVALID_PAGE_TOKEN | The page_token is malformed, was issued for a different q, or was issued before a change to search ordering. |
| 400 | INVALID_PAGE_SIZE | The page_size is negative. |
| 400 | EMPTY_BATCH | A batch request names no identifiers. |
| 400 | BATCH_TOO_LARGE | A batch request names more than 50 identifiers; metadata "max_identifiers" is the limit. |
| 400 | INVALID_REQUEST | The request is malformed. |
| 404 | NOT_FOUND | There is no such endpoint. |
| 405 | METHOD_NOT_ALLOWED | The endpoint does not accept that HTTP method. |
| 413 | REQUEST_TOO_LARGE | The request body is over 64 KiB. Retrying the same request cannot succeed; send less. |
| 429 | RATE_LIMITED | Too many requests; metadata "retry_after_seconds" repeats Retry-After. |
| 500 | INTERNAL | DropHawk failed; retry later. |
| 503 | UNAVAILABLE | DropHawk is briefly unable to serve; retry later. |
New reasons may be added within v1, as the versioning and deprecation policy allows.
Retrying
PRODUCT_NOT_FOUND,INVALID_IDENTIFIER,INVALID_REQUEST,NOT_FOUNDandMETHOD_NOT_ALLOWEDwill fail the same way again. Fix the request instead of retrying it.RATE_LIMITEDsucceeds once you wait: theRetry-Afterheader, and theretry_after_secondsmetadata, say how many seconds. See Rate limits.INTERNALandUNAVAILABLE, and any other5xx, mean something failed on DropHawk's side or it is briefly unable to serve. Retry with exponential backoff.
Error responses are sent with Cache-Control: no-store, so no cache keeps a 404 after the Product appears; see CORS and caching.
Connect and gRPC
A Connect or gRPC client gets its protocol's own error model instead of the JSON above, carrying the same ErrorInfo whenever the API raised the error.
A request counts as Connect or gRPC only when it carries a protocol marker: a Connect-Protocol-Version header, connect=v1 in a Connect GET's query, or a gRPC, gRPC-Web or Connect streaming Content-Type.
Without one, even a GET to an RPC path such as /drophawk.developer.v1.ProductService/GetProduct is HTTP/JSON, and gets the JSON error above (404 with NOT_FOUND).
The message is the error code's name in every protocol, so branch on the reason there too.
Errors the RPC framework raises before the API sees the request carry no ErrorInfo:
- a request body that does not decode:
invalid_argument, with the messageinvalid request body; - a request body over 64 KiB:
resource_exhausted- not rate limiting, which always carriesRATE_LIMITED; - a method that does not exist.
Handle a missing ErrorInfo by the error code.
Not errors
A 301 Moved Permanently means the Product was merged into another.
Follow Location, and update the ModelSlug you stored; see Merged Products.
Reserved statuses
401 and 403 are reserved for a future keyed tier and are not returned in v1; see Authentication.
