You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
API: router HeaderMatch "present_match" field is a bool but value is ignored #14656
This means that if present_match=false, it matches when the header is present, which is extremely counter-intuitive. And the behavior is certainly not obvious to someone reading the proto file. In gRPC, we assumed that because it's a boolean field that the value actually mattered, so we implemented it such that if the value is false, the match is true only if the header is not present. This means that Envoy and gRPC are behaving differently here.
@htuch did some digging for me and found that this field was added in #3443, at the same time as the invert_match field. Perhaps the thinking was that since there was a separate way to invert any match type, setting present_match (to any value) and invert_match=true is the right way to match on the absence of a field. However, in that case, it would have made more sense for the present_match field to be of type google.protobuf.Empty instead of being a boolean.
I think we need to choose one of the following options:
Define the correct behavior as gRPC's behavior. This is a boolean field, which means that a value of false indicates that the header must be absent (which means that {present_match=false, invert_match=true} is the same as {present_match=true, invert_match=false}). In this case, we can simply change Envoy's implementation to match gRPC's, and no API changes are needed.
Define the correct behavior as Envoy's behavior. In this case, the API is wrong, and we should deprecate the existing present_match field and replace it with a new one with type google.protobuf.Empty, so that the semantics are no longer confusing.
I'd ideally like to go with (1), because it's less work overall and leaves us with less API cruft. But I don't know what the risk of breaking existing users is, because I don't know if anyone is actually setting this field to false and relying on the existing behavior.
I think this is just a bug in that the field is missing a validation that forces it to always be true (which is a pattern we have elsewhere versus using Empty but is semantically the same). I don't have a strong opinion. I think (1) is fine, or we can just add a force true validation to the proto which IMO doesn't require a deprecation because it was probably the implied mode of operation.
changed the title [-]API: router HeaderMatch "present" field is a bool but value is ignored[/-][+]API: router HeaderMatch "present_match" field is a bool but value is ignored[/+]on Jan 12, 2021
Using a bool with a validation that forces it to be true seems like an anti-pattern to me. I think that someone reading the API should be able to understand the semantics from the type, and bool implies that there are two possible values, not just one. I think that using Empty is much cleaner for this kind of case.
Anyway, if we all think that (1) is fine, then let's just go with that. Thanks!
Using a bool with a validation that forces it to be true seems like an anti-pattern to me. I think that someone reading the API should be able to understand the semantics from the type, and bool implies that there are two possible values, not just one. I think that using Empty is much cleaner for this kind of case.
I think you are right, but for better or worse that is not what has been done so far.
Activity
htuch commentedon Jan 12, 2021
I would argue (1) is fine, CC @gumpt @mattklein123
mattklein123 commentedon Jan 12, 2021
I think this is just a bug in that the field is missing a validation that forces it to always be true (which is a pattern we have elsewhere versus using Empty but is semantically the same). I don't have a strong opinion. I think (1) is fine, or we can just add a force true validation to the proto which IMO doesn't require a deprecation because it was probably the implied mode of operation.
[-]API: router HeaderMatch "present" field is a bool but value is ignored[/-][+]API: router HeaderMatch "present_match" field is a bool but value is ignored[/+]markdroth commentedon Jan 12, 2021
Using a bool with a validation that forces it to be true seems like an anti-pattern to me. I think that someone reading the API should be able to understand the semantics from the type, and bool implies that there are two possible values, not just one. I think that using
Emptyis much cleaner for this kind of case.Anyway, if we all think that (1) is fine, then let's just go with that. Thanks!
mattklein123 commentedon Jan 12, 2021
I think you are right, but for better or worse that is not what has been done so far.
htuch commentedon Jan 13, 2021
@markdroth are you signing up to adjust Envoy's behavior here? :)
soulxu commentedon May 22, 2021
@markdroth @htuch I worked out a PR for this issue.