Skip to content
Snippets Groups Projects
Commit 023c9822 authored by Mark D. Roth's avatar Mark D. Roth Committed by GitHub
Browse files

Merge pull request #10612 from markdroth/max_message_size_status_code

Use RESOURCE_EXHAUSTED for max message size limits.
parents 2d89ac44 17a93b33
No related branches found
No related tags found
No related merge requests found
# Status codes and their use in gRPC # Status codes and their use in gRPC
gRPC uses a set of well defined status codes as part of the RPC API. All RPCs started at a client return a `status` object composed of an integer `code` and a string `message`. The server-side can choose the status it returns for a given RPC. gRPC uses a set of well defined status codes as part of the RPC API. All
RPCs started at a client return a `status` object composed of an integer
`code` and a string `message`. The server-side can choose the status it
returns for a given RPC.
The gRPC client and server-side implementations may also generate and return `status` on their own when errors happen. The gRPC client and server-side implementations may also generate and
Only a subset of the pre-defined status codes are generated by the gRPC libraries. The following table lists these codes and summarizes the situations in which they are generated, either by the client or the server-side library implementation. return `status` on their own when errors happen. Only a subset of
the pre-defined status codes are generated by the gRPC libraries. This
allows applications to be sure that any other code it sees was actually
returned by the application (although it is also possible for the
server-side to return one of the codes generated by the gRPC libraries).
The following table lists the codes that may be returned by the gRPC
libraries (on either the client-side or server-side) and summarizes the
situations in which they are generated.
| Case | Code | Generated at Client or Server | | Case | Code | Generated at Client or Server |
| ------------- |:-------------| :-----:| | ------------- |:-------------| :-----:|
...@@ -26,7 +37,7 @@ Only a subset of the pre-defined status codes are generated by the gRPC librarie ...@@ -26,7 +37,7 @@ Only a subset of the pre-defined status codes are generated by the gRPC librarie
| Response cardinality violation (method requires exactly one response but server sent some other number of responses) | UNIMPLEMENTED | Client| | Response cardinality violation (method requires exactly one response but server sent some other number of responses) | UNIMPLEMENTED | Client|
| Error parsing response proto | INTERNAL | Client| | Error parsing response proto | INTERNAL | Client|
| Error parsing request proto | INTERNAL | Server| | Error parsing request proto | INTERNAL | Server|
| Sent or received message was larger than configured limit | RESOURCE_EXHAUSTED | Both |
The following status codes are never generated by the library: The following status codes are never generated by the library:
- INVALID_ARGUMENT - INVALID_ARGUMENT
......
...@@ -122,7 +122,7 @@ static void recv_message_ready(grpc_exec_ctx* exec_ctx, void* user_data, ...@@ -122,7 +122,7 @@ static void recv_message_ready(grpc_exec_ctx* exec_ctx, void* user_data,
(*calld->recv_message)->length, calld->max_recv_size); (*calld->recv_message)->length, calld->max_recv_size);
grpc_error* new_error = grpc_error_set_int( grpc_error* new_error = grpc_error_set_int(
GRPC_ERROR_CREATE_FROM_COPIED_STRING(message_string), GRPC_ERROR_CREATE_FROM_COPIED_STRING(message_string),
GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_INVALID_ARGUMENT); GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_RESOURCE_EXHAUSTED);
if (error == GRPC_ERROR_NONE) { if (error == GRPC_ERROR_NONE) {
error = new_error; error = new_error;
} else { } else {
...@@ -152,7 +152,7 @@ static void start_transport_stream_op_batch( ...@@ -152,7 +152,7 @@ static void start_transport_stream_op_batch(
exec_ctx, op, exec_ctx, op,
grpc_error_set_int(GRPC_ERROR_CREATE_FROM_COPIED_STRING(message_string), grpc_error_set_int(GRPC_ERROR_CREATE_FROM_COPIED_STRING(message_string),
GRPC_ERROR_INT_GRPC_STATUS, GRPC_ERROR_INT_GRPC_STATUS,
GRPC_STATUS_INVALID_ARGUMENT)); GRPC_STATUS_RESOURCE_EXHAUSTED));
gpr_free(message_string); gpr_free(message_string);
return; return;
} }
......
...@@ -272,7 +272,7 @@ static void test_max_message_length_on_request(grpc_end2end_test_config config, ...@@ -272,7 +272,7 @@ static void test_max_message_length_on_request(grpc_end2end_test_config config,
GPR_ASSERT(was_cancelled == 1); GPR_ASSERT(was_cancelled == 1);
done: done:
GPR_ASSERT(status == GRPC_STATUS_INVALID_ARGUMENT); GPR_ASSERT(status == GRPC_STATUS_RESOURCE_EXHAUSTED);
GPR_ASSERT( GPR_ASSERT(
grpc_slice_str_cmp( grpc_slice_str_cmp(
details, send_limit details, send_limit
...@@ -466,7 +466,7 @@ static void test_max_message_length_on_response(grpc_end2end_test_config config, ...@@ -466,7 +466,7 @@ static void test_max_message_length_on_response(grpc_end2end_test_config config,
GPR_ASSERT(0 == GPR_ASSERT(0 ==
grpc_slice_str_cmp(call_details.host, "foo.test.google.fr:1234")); grpc_slice_str_cmp(call_details.host, "foo.test.google.fr:1234"));
GPR_ASSERT(status == GRPC_STATUS_INVALID_ARGUMENT); GPR_ASSERT(status == GRPC_STATUS_RESOURCE_EXHAUSTED);
GPR_ASSERT( GPR_ASSERT(
grpc_slice_str_cmp( grpc_slice_str_cmp(
details, send_limit details, send_limit
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment