Skip to content
Skip to Content
DropHawk.Developers

Errors and reasons

An HTTP/JSON error is an Error carrying an ErrorInfo. Branch on its reason, not the message.

View as Markdown

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"
    }
  ]
}
  • code is the gRPC status code that matches the HTTP status (5 is NOT_FOUND).
  • message is the code's name, such as not_found: stable, for logs, and not for display.
  • details holds an ErrorInfo, whose @type is type.googleapis.com/google.rpc.ErrorInfo and whose domain is drophawk.net. Its reason is what to branch on: one HTTP status can be shared by several causes. Some reasons add context in metadata, 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

HTTPReasonMeaning
404PRODUCT_NOT_FOUNDNo Product is known by the identifier, or it has been removed from the catalog.
400INVALID_IDENTIFIERThe identifier cannot name any Product.
400INVALID_QUERYThe search query q is blank, over 256 bytes, or has control characters.
400INVALID_PAGE_TOKENThe page_token is malformed, was issued for a different q, or was issued before a change to search ordering.
400INVALID_PAGE_SIZEThe page_size is negative.
400EMPTY_BATCHA batch request names no identifiers.
400BATCH_TOO_LARGEA batch request names more than 50 identifiers; metadata "max_identifiers" is the limit.
400INVALID_REQUESTThe request is malformed.
404NOT_FOUNDThere is no such endpoint.
405METHOD_NOT_ALLOWEDThe endpoint does not accept that HTTP method.
413REQUEST_TOO_LARGEThe request body is over 64 KiB. Retrying the same request cannot succeed; send less.
429RATE_LIMITEDToo many requests; metadata "retry_after_seconds" repeats Retry-After.
500INTERNALDropHawk failed; retry later.
503UNAVAILABLEDropHawk 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_FOUND and METHOD_NOT_ALLOWED will fail the same way again. Fix the request instead of retrying it.
  • RATE_LIMITED succeeds once you wait: the Retry-After header, and the retry_after_seconds metadata, say how many seconds. See Rate limits.
  • INTERNAL and UNAVAILABLE, and any other 5xx, 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 message invalid request body;
  • a request body over 64 KiB: resource_exhausted - not rate limiting, which always carries RATE_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.