xds: convert rds header exact/prefix/suffix/contains matches to StringMatcher (#9223)
The RDS parser stored a header matcher's exact_match, prefix_match, or
suffix_match without checking for the empty string, so a route carrying
`exact_match: ""` (a valid proto oneof selection) was accepted.
RouteToMatcher later tested those fields with `*h.X != ""` and treated
an empty value as unset, so it fell through every arm of its header
switch to `panic("illegal route: missing header_match_specifier")`. That
runs when the client resolver builds a config selector and when the
server processes an inline route config, neither behind a recover, so a
management server could crash the client or an xds-enabled server with a
single route.
Per review feedback, instead of adding per-field empty checks the parser
now converts the deprecated exact_match, prefix_match, suffix_match, and
contains_match fields to the equivalent StringMatcher and runs them
through matcher.StringMatcherFromProto, so validation for all of them is
consolidated in one place. As a result:
* an empty prefix_match, suffix_match, or contains_match is rejected and
the resource is NACKed
* an empty exact_match is accepted and matches an empty header value,
per StringMatcher semantics, instead of panicking
* contains_match is now supported for route header matching
* RouteToMatcher drops its per-field `!= ""` special casing, and the
ExactMatch/PrefixMatch/SuffixMatch fields are removed from the internal
HeaderMatcher type
RELEASE NOTES:
* xds: fix a panic parsing a route whose header matcher has an empty
exact_match, prefix_match, or suffix_match, and add support for
contains_match in route header matchers N
Naveed committed
e57a05f0ecdcfaeae917795b9ed4cacce9254e61
Parent: 2ac9758
Committed by GitHub <noreply@github.com>
on 7/24/2026, 9:36:08 AM