1# HTTP to gRPC Status Code Mapping
2
3Since intermediaries are a common part of HTTP infrastructure some responses to
4gRPC requests may be received that do not include the grpc-status header. In
5some cases mapping error codes from an intermediary allows the gRPC client to
6behave more appropriately to the error situation without overloading the
7semantics of either error code.
8
9This table is to be used _only_ for clients that received a response that did
10not include grpc-status. If grpc-status was provided, it _must_ be used. Servers
11_must not_ use this table to determine an HTTP status code to use; the mappings
12are neither symmetric nor 1-to-1.
13
14| HTTP Status Code           | gRPC Status Code   |
15|----------------------------|--------------------|
16| 400 Bad Request            | INTERNAL           |
17| 401 Unauthorized           | UNAUTHENTICATED    |
18| 403 Forbidden              | PERMISSION\_DENIED |
19| 404 Not Found              | UNIMPLEMENTED      |
20| 429 Too Many Requests      | UNAVAILABLE        |
21| 502 Bad Gateway            | UNAVAILABLE        |
22| 503 Service Unavailable    | UNAVAILABLE        |
23| 504 Gateway Timeout        | UNAVAILABLE        |
24| _All other codes_          | UNKNOWN            |
25
26Technically, 1xx should have the entire header skipped and a subsequent header
27be read. See RFC 7540 §8.1.
28
29200 is UNKNOWN because there should be a grpc-status in case of truly OK
30response.
31