Add more info to metadata limit exceeded error (#31756)

* Add more info to error

* Fix tests
pull/31762/head
Alisha Nanda 2 years ago committed by GitHub
parent ddc5a62409
commit 694e4b8427
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 14
      src/core/ext/transport/chttp2/transport/hpack_parser.cc
  2. 7
      test/core/end2end/tests/large_metadata.cc

@ -26,6 +26,7 @@
#include <stdlib.h>
#include <algorithm>
#include <cinttypes>
#include <string>
#include <utility>
@ -1190,16 +1191,15 @@ class HPackParser::Parser {
GPR_ATTRIBUTE_NOINLINE
bool HandleMetadataSizeLimitExceeded(const HPackTable::Memento&) {
gpr_log(GPR_DEBUG,
"received initial metadata size exceeds limit (%" PRIu32
" vs. %" PRIu32
"). GRPC_ARG_MAX_METADATA_SIZE can be set to increase this limit.",
*frame_length_, metadata_size_limit_);
if (metadata_buffer_ != nullptr) metadata_buffer_->Clear();
// TODO(alishananda): add debug log with metadata details
return input_->MaybeSetErrorAndReturn(
[] {
[this] {
return grpc_error_set_int(
GRPC_ERROR_CREATE("received initial metadata size exceeds limit"),
GRPC_ERROR_CREATE(absl::StrFormat(
"received initial metadata size exceeds limit (%" PRIu32
" vs. %" PRIu32 ")",
*frame_length_, metadata_size_limit_)),
StatusIntProperty::kRpcStatus, GRPC_STATUS_RESOURCE_EXHAUSTED);
},
false);

@ -353,10 +353,13 @@ static void test_request_with_bad_large_metadata_response(
cqv.Verify();
GPR_ASSERT(status == GRPC_STATUS_RESOURCE_EXHAUSTED);
GPR_ASSERT(0 == grpc_slice_str_cmp(
details, "received initial metadata size exceeds limit"));
const char* expected_error = "received initial metadata size exceeds limit";
grpc_slice actual_error =
grpc_slice_split_head(&details, strlen(expected_error));
GPR_ASSERT(0 == grpc_slice_str_cmp(actual_error, expected_error));
GPR_ASSERT(0 == grpc_slice_str_cmp(call_details.method, "/foo"));
grpc_slice_unref(actual_error);
grpc_slice_unref(details);
grpc_metadata_array_destroy(&initial_metadata_recv);
grpc_metadata_array_destroy(&trailing_metadata_recv);

Loading…
Cancel
Save