Update triple slash comments on QueryParameterMatchMode and HeaderMatchMode - #3049
Closed
Benziza wants to merge 1 commit into
Closed
Update triple slash comments on QueryParameterMatchMode and HeaderMatchMode#3049Benziza wants to merge 1 commit into
Benziza wants to merge 1 commit into
Conversation
…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.
Author
|
@dotnet-policy-service agree |
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.
Follow-up to #2000, which updated these comments on
HeaderMatchModebut left two gaps. Comments only, no behavior change.1.
QueryParameterMatchModewas 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 ofQueryParameterMatchMode:QueryParameterMatcherPolicyiterates 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 byQueryMatcherPolicyTests:which builds
?org-id=a&org-id=abcand expects a match.The same block also claims the value must match "for each of the respective query string values" on
ContainsandPrefix, where the matcher is an any-of.2.
NotContainsandNotExistsdrifted again after #2260HeaderMatchMode.NotContainscurrently opens with: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.NotContainshas the same stale "key must be present" claim.NotExistssays "The header must not exist", while a header that is present with an empty value also matches.Both behaviors are already pinned by
HeaderMatcherPolicyTests:Observed on the shipped 2.3.0 package
NotContainsonX-Client-Type, header absentNotContainsonX-Client-Type, header present but emptyNotExistsonX-Client-Type, header present but emptyExactonenv=prod, request?env=test&env=prodThe wording added here follows the phrasing #2000 introduced for headers.
Verification
build.cmd -projects src\ReverseProxy\Yarp.ReverseProxy.csprojsucceeds with 0 warnings and 0 errors, andbuild.cmd -test -projects test\ReverseProxy.Tests\Yarp.ReverseProxy.Tests.csprojpasses on both net8.0 and net9.0.No test changes were needed: the existing tests already assert the behavior described here.