Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[grpc-transcoder] Add option to pack unknown parameters into HttpBody extension #34999

Merged
merged 5 commits into from
Jul 9, 2024

Conversation

ravenblackx
Copy link
Contributor

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

… extension

Signed-off-by: Raven Black <ravenblack@dropbox.com>
Copy link

As a reminder, PRs marked as draft will not be automatically assigned reviewers,
or be handled by maintainer-oncall triage.

Please mark your PR as ready when you want it to be reviewed!

🐱

Caused by: #34999 was opened by ravenblackx.

see: more, trace.

Copy link

CC @envoyproxy/api-shepherds: Your approval is needed for changes made to (api/envoy/|docs/root/api-docs/).
envoyproxy/api-shepherds assignee is @markdroth
CC @envoyproxy/api-watchers: FYI only for changes made to (api/envoy/|docs/root/api-docs/).

🐱

Caused by: #34999 was opened by ravenblackx.

see: more, trace.

@ravenblackx ravenblackx marked this pull request as ready for review July 1, 2024 18:13
@ravenblackx ravenblackx requested a review from alyssawilk as a code owner July 1, 2024 18:13
@ravenblackx
Copy link
Contributor Author

/retest

2 similar comments
@ravenblackx
Copy link
Contributor Author

/retest

@ravenblackx
Copy link
Contributor Author

/retest

@markdroth
Copy link
Contributor

/lgtm api

Copy link
Contributor

@alyssawilk alyssawilk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems useful, some thoughts below
/wait

// If true, query parameters that cannot be mapped to a corresponding
// protobuf field are captured in an HttpBody extension of UnknownVariableBindings.
// This overrides ``ignore_unknown_query_parameters`` and ``reject_unknown_query_parameters``.
bool capture_unknown_query_parameters = 17;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO rather than override we should reject a config which suggests doing 2 different things to unknown config params.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes a transition to this new behavior difficult for us, because config and binary can be pushed separately and we're currently operating on a patch that does the new behavior with the old config.

The transition plan for me is to push a new config that specifies both the things, then push the new binary, thereby rolling onto the non-patch implementation of the behavior.

I'd be much more comfortable if I could make this change in a followup if that would be okay?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think API changes which make previously valid config invalid are disallowed unfortunately.
Options would be to have a runtime guard default-false for the allow behavior, and you could flip it internally, or just allow it and I will put up with it with mild crankiness as I have in the myriad other instances I've asked folks to not allow for confusing behavior and the harsh realities of production have made it impossible =P

As a compromise how about at least logging a warning below if the prior config knob is ignored?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I started to do that, then realized it doesn't make sense - "warning, your ignore directive is being ignored in favor of another setting that does still ignore it in the way you meant".

So instead I made the protodoc less confusing about what overrides what; capture doesn't really override ignore, it just also does ignore whether you set both or not. The only thing it really overrides is the same thing ignore also overrides, and that wasn't documented on ignore, it was only documented on the overridden field, so I've made the documentation for the new field match that.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well in that case there should be a warning for both ignore and send iff strict but there's prior art for not warning about that so I'm just going to declare myself an api grinch and LGTM this.

// ``UnknownVariableBindings`` 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 UnknownVariableBindings {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ooc why bindings rather than UnknownQueryParams or something?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because renaming it would be a massive deployment pain for us, as this message is all throughout a whole bunch of client code already. :D

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On second thought, maybe it makes more sense to bind this with a different extension with a better API, have the patch and the new one both operating during the transition with the client preferring the new encoding, and that way I can do an API that isn't as bad as the original one.

proto_config.set_capture_unknown_query_parameters(true);
JsonTranscoderConfig config(proto_config, *api_);

Http::TestRequestHeaderMapImpl headers{{":method", "GET"}, {":path", "/shelves?foo=bar"}};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you test with multiple query params, and multiple params with the same name?
e.g. foo=bar+dsa&eep=baz&foo=asd?

just want to make sure we're thoughtful about the lack of normalization here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, along with an updated API that does key -> [values] rather than key -> value

Signed-off-by: Raven Black <ravenblack@dropbox.com>
Signed-off-by: Raven Black <ravenblack@dropbox.com>
Signed-off-by: Raven Black <ravenblack@dropbox.com>
@repokitteh-read-only repokitteh-read-only bot added api and removed waiting labels Jul 8, 2024
Copy link
Contributor

@alyssawilk alyssawilk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LG modulo a warning for conflicting config

// If true, query parameters that cannot be mapped to a corresponding
// protobuf field are captured in an HttpBody extension of UnknownVariableBindings.
// This overrides ``ignore_unknown_query_parameters`` and ``reject_unknown_query_parameters``.
bool capture_unknown_query_parameters = 17;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think API changes which make previously valid config invalid are disallowed unfortunately.
Options would be to have a runtime guard default-false for the allow behavior, and you could flip it internally, or just allow it and I will put up with it with mild crankiness as I have in the myriad other instances I've asked folks to not allow for confusing behavior and the harsh realities of production have made it impossible =P

As a compromise how about at least logging a warning below if the prior config knob is ignored?

Signed-off-by: Raven Black <ravenblack@dropbox.com>
// If true, query parameters that cannot be mapped to a corresponding
// protobuf field are captured in an HttpBody extension of UnknownVariableBindings.
// This overrides ``ignore_unknown_query_parameters`` and ``reject_unknown_query_parameters``.
bool capture_unknown_query_parameters = 17;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well in that case there should be a warning for both ignore and send iff strict but there's prior art for not warning about that so I'm just going to declare myself an api grinch and LGTM this.

@ravenblackx ravenblackx requested a review from markdroth July 9, 2024 17:41
@alyssawilk alyssawilk merged commit f837c48 into envoyproxy:main Jul 9, 2024
51 of 52 checks passed
@ravenblackx ravenblackx deleted the unknown-var branch July 10, 2024 20:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[grpc-transcoding] Transcode unknown variable bindings
3 participants