xds: ignore keep_empty_value and discard header keys on empty mutations#12852
Open
kannanjgithub wants to merge 1 commit into
Open
xds: ignore keep_empty_value and discard header keys on empty mutations#12852kannanjgithub wants to merge 1 commit into
kannanjgithub wants to merge 1 commit into
Conversation
In GrpcService/ext_proc header mutations, we do not support the `keep_empty_value` field (grpc/proposal@f6d42d6). If any header mutation results in a header containing an empty value (either string or binary), the entire header key is discarded/removed from the metadata. This chang modifies HeaderMutator to apply mutations and discard keys containing empty values.
Contributor
|
/gemini review |
Contributor
|
/gemini-review |
There was a problem hiding this comment.
Code Review
This pull request refactors the header mutation logic in HeaderMutator.java to discard headers containing empty values, updating the corresponding test cases in HeaderMutatorTest.java to reflect this change. A review comment suggests that the newly added containsEmpty helper method is redundant and can be safely removed.
Comment on lines
+122
to
+139
| private <T> boolean containsEmpty(Metadata.Key<T> key, Metadata headers) { | ||
| Iterable<T> values = headers.getAll(key); | ||
| if (values == null) { | ||
| return false; | ||
| } | ||
| for (T val : values) { | ||
| if (val instanceof String) { | ||
| if (((String) val).isEmpty()) { | ||
| return true; | ||
| } | ||
| } else if (val instanceof byte[]) { | ||
| if (((byte[]) val).length == 0) { | ||
| return true; | ||
| } | ||
| } | ||
| } | ||
| return false; | ||
| } |
Contributor
There was a problem hiding this comment.
We might want to investigate the need for this function. I've added a comment here previously grpc/proposal#481 (comment)
about compliance with envoy behavior.
sauravzg
reviewed
Jun 10, 2026
| private void updateHeader(final HeaderValueOption option, Metadata mutableHeaders) { | ||
| HeaderValue header = option.header(); | ||
| HeaderAppendAction action = option.appendAction(); | ||
| boolean keepEmptyValue = option.keepEmptyValue(); |
Contributor
There was a problem hiding this comment.
We should probably delete the config field as well if unused.
sauravzg
approved these changes
Jun 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In GrpcService/ext_proc header mutations, we do not support the
keep_empty_valuefield (grpc/proposal@f6d42d6). If any header mutation results in a header containing an empty value (either string or binary), the entire header key is discarded/removed from the metadata.This change modifies HeaderMutator to apply mutations and discard keys containing empty values.