Skip to content

Update triple slash comments on QueryParameterMatchMode and HeaderMatchMode - #3049

Closed
Benziza wants to merge 1 commit into
dotnet:mainfrom
Benziza:docs/matchmode-comments
Closed

Update triple slash comments on QueryParameterMatchMode and HeaderMatchMode#3049
Benziza wants to merge 1 commit into
dotnet:mainfrom
Benziza:docs/matchmode-comments

Conversation

@Benziza

@Benziza Benziza commented Aug 15, 2026

Copy link
Copy Markdown

Follow-up to #2000, which updated these comments on HeaderMatchMode but left two gaps. Comments only, no behavior change.

1. QueryParameterMatchMode was not covered by #2000

#2000 removed "Only single headers are supported. If there are multiple headers with the same name then the match fails." from HeaderMatchMode, but the equivalent sentence is still on four members of QueryParameterMatchMode:

Only single query parameter name supported. If there are multiple query parameters with the same name then the match fails.

QueryParameterMatcherPolicy iterates over every value bound to the name and matches if any of them matches, so a repeated name does not fail the match. This is already asserted by QueryMatcherPolicyTests:

[InlineData("abc", QueryParameterMatchMode.Exact, true, "a;abc", true)]

which builds ?org-id=a&org-id=abc and expects a match.

The same block also claims the value must match "for each of the respective query string values" on Contains and Prefix, where the matcher is an any-of.

2. NotContains and NotExists drifted again after #2260

HeaderMatchMode.NotContains currently opens with:

The header must exist and the value must be non-empty.

That was accurate when #2000 was written, but the fix for #2260 deliberately made a missing or empty header match, and the comment was not updated. QueryParameterMatchMode.NotContains has the same stale "key must be present" claim.

NotExists says "The header must not exist", while a header that is present with an empty value also matches.

Both behaviors are already pinned by HeaderMatcherPolicyTests:

[InlineData(null, HeaderMatchMode.NotExists, true)]
[InlineData("", HeaderMatchMode.NotExists, true)]   // present but empty -> matches
[InlineData("abc", HeaderMatchMode.NotContains, false, null, true)]
[InlineData("abc", HeaderMatchMode.NotContains, false, "", true)]

Observed on the shipped 2.3.0 package

Route match Comment predicts Actual
NotContains on X-Client-Type, header absent no match match
NotContains on X-Client-Type, header present but empty no match match
NotExists on X-Client-Type, header present but empty no match match
Exact on env=prod, request ?env=test&env=prod no match match

The wording added here follows the phrasing #2000 introduced for headers.

Verification

build.cmd -projects src\ReverseProxy\Yarp.ReverseProxy.csproj succeeds with 0 warnings and 0 errors, and build.cmd -test -projects test\ReverseProxy.Tests\Yarp.ReverseProxy.Tests.csproj passes on both net8.0 and net9.0.

No test changes were needed: the existing tests already assert the behavior described here.

…chMode

These comments no longer describe what the matchers actually do.

QueryParameterMatchMode still carries the "Only single query parameter
name supported. If there are multiple query parameters with the same
name then the match fails." wording that dotnet#2000 removed from
HeaderMatchMode. QueryParameterMatcherPolicy iterates over every value
for the name and matches if any of them matches, so a repeated name does
not fail the match.

HeaderMatchMode.NotContains still says "The header must exist and the
value must be non-empty", which was correct when dotnet#2000 was written but
stopped being true after the fix for dotnet#2260 made a missing or empty
header match. QueryParameterMatchMode.NotContains has the same problem.

NotExists also matches a header that is present with an empty value, not
only a header that is absent.

Comments only, no behavior change.
@Benziza
Benziza requested a review from MihaZupan as a code owner August 15, 2026 11:07
@Benziza

Benziza commented Aug 15, 2026

Copy link
Copy Markdown
Author

@dotnet-policy-service agree

@Benziza Benziza closed this Aug 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant