From f6c776a92b6774877a68789a58aeb54ac78156b4 Mon Sep 17 00:00:00 2001 From: "update-envoy[bot]" <135279899+update-envoy[bot]@users.noreply.github.com> Date: Tue, 9 Jul 2024 20:14:03 +0000 Subject: [PATCH] [grpc-transcoder] Add option to pack unknown parameters into HttpBody extension (#34999) Commit Message: [grpc-transcoder] Add option to pack unknown parameters into HttpBody extension Additional Description: We've been using this behavior for years, with PR #15338 as a patch. Finally getting around to trying to upstream the behavior to make it available for others, and to make it so I don't have to keep repositioning the patch. Unlike #15338 I'm also adding a configuration option so that no behavior change will occur without a corresponding configuration change. Risk Level: Very low, guarded by a new config field. Testing: Added positive unit tests, added conditions to other tests for the negative case. Docs Changes: Autogen Fixes #14710 --------- Signed-off-by: Raven Black Mirrored from https://github.com/envoyproxy/envoy @ f837c480adad94e8d1a05ef648c26ffce7ecd286 --- .../grpc_json_transcoder/v3/transcoder.proto | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/envoy/extensions/filters/http/grpc_json_transcoder/v3/transcoder.proto b/envoy/extensions/filters/http/grpc_json_transcoder/v3/transcoder.proto index bcea4239..4fcf1b98 100644 --- a/envoy/extensions/filters/http/grpc_json_transcoder/v3/transcoder.proto +++ b/envoy/extensions/filters/http/grpc_json_transcoder/v3/transcoder.proto @@ -18,7 +18,7 @@ option (udpa.annotations.file_status).package_version_status = ACTIVE; // gRPC-JSON transcoder :ref:`configuration overview `. // [#extension: envoy.filters.http.grpc_json_transcoder] -// [#next-free-field: 17] +// [#next-free-field: 18] // GrpcJsonTranscoder filter configuration. // The filter itself can be used per route / per virtual host or on the general level. The most // specific one is being used for a given route. If the list of services is empty - filter @@ -88,7 +88,8 @@ message GrpcJsonTranscoder { // When set to true, the request will be rejected with a ``HTTP 400 Bad Request``. // // The fields - // :ref:`ignore_unknown_query_parameters ` + // :ref:`ignore_unknown_query_parameters `, + // :ref:`capture_unknown_query_parameters `, // and // :ref:`ignored_query_parameters ` // have priority over this strict validation behavior. @@ -288,4 +289,20 @@ message GrpcJsonTranscoder { // // If unset, the current stream buffer size is used. google.protobuf.UInt32Value max_response_body_size = 16 [(validate.rules).uint32 = {gt: 0}]; + + // If true, query parameters that cannot be mapped to a corresponding + // protobuf field are captured in an HttpBody extension of UnknownQueryParams. + bool capture_unknown_query_parameters = 17; +} + +// ``UnknownQueryParams`` is added as an extension field in ``HttpBody`` if +// ``GrpcJsonTranscoder::capture_unknown_query_parameters`` is true and unknown query +// parameters were present in the request. +message UnknownQueryParams { + message Values { + repeated string values = 1; + } + + // A map from unrecognized query parameter keys, to the values associated with those keys. + map key = 1; }