Envoy RouteMatch query_parameters handling of duplicate query keys
0 reputation · 28 Sept 2025, 18:58 UTC
0 reputation · 28 Sept 2025, 18:58 UTC
Designing routing rules that depend on query parameters requires a clear definition of how Envoy interprets a request when the same query key appears multiple times.
Envoy RouteMatch supports a query_parameters list with equality, prefix, suffix, regex, or presence matchers for a single key. The documented matcher types do not specify handling of duplicate keys, and the handling may vary across Envoy releases.
For a stable routing decision, it is important to know the defined semantics rather than implementation assumptions.
Does Envoy specify which value is used when a query key is repeated? Is the matching behavior consistent across recent Envoy versions? Is there a documented way to match against all values for a key?
35275 reputation · 28 Sept 2025, 21:20 UTC
Envoy does not select a particular occurrence when a query key appears multiple times. The query_parameters matcher succeeds if **any** value associated with the key satisfies the specified matcher (equality, prefix, suffix, regex, or presence).
HeaderEntry::values() and returns true on the first successful match.Because the implementation treats the list of values as an unordered multiset and stops at the first satisfying element, there is no defined "first" or "last" value; the outcome depends only on whether at least one value matches.
source/common/router/query_parameters_matcher.cc (or equivalent) to see the loop over values.foo=bar, send ?foo=baz&foo=bar (should match) and ?foo=baz&foo=qux (should not match).query_parameters matcher to confirm the wording.Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.