Skip to content

Fix WithParam RejectOnMatch inverting the match result #1496 - #1497

Open
Bafyn wants to merge 1 commit into
wiremock:masterfrom
Bafyn:fix/withparam-rejectonmatch-inverted
Open

Fix WithParam RejectOnMatch inverting the match result #1496#1497
Bafyn wants to merge 1 commit into
wiremock:masterfrom
Bafyn:fix/withparam-rejectonmatch-inverted

Conversation

@Bafyn

@Bafyn Bafyn commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Problem

WithParam(key, MatchBehaviour.RejectOnMatch, values) returns the opposite result: a request whose param value equals the reject value matches (should be rejected), and a different value doesn't match (should be accepted). AcceptOnMatch is unaffected.

Cause

RequestMessageParamMatcher's params string[] values ctor injects matchBehaviour into each inner ExactMatcher (which already runs MatchBehaviourHelper.Convert), and GetMatchingScore runs Convert again on the aggregate - so it's applied twice.

Fix

Create the inner ExactMatcher with AcceptOnMatch; the behaviour is now applied once by GetMatchingScore. AcceptOnMatch output is unchanged.

Tests

  • Unit: RequestMessageParamMatcherTests => RejectOnMatch match/non-match (+ignoreCase) and AcceptOnMatch regressions.
  • E2E: WireMockServerTests.WithParam: ?k=abc => 404, ?k=xyz => 200.

References

Fixes #1496

Submitter checklist

  • The PR request is well described and justified, including the body and the references
  • The PR title represents the desired changelog entry
  • The repository's code style is followed (see the contributing guide)
  • Test coverage that demonstrates that the change works as expected

@StefH StefH added the bug Something isn't working label Aug 10, 2026
@Bafyn
Bafyn force-pushed the fix/withparam-rejectonmatch-inverted branch from 37a7eb8 to ab0825f Compare August 11, 2026 19:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

WithParam(key, MatchBehaviour.RejectOnMatch, values) inverts the match result

2 participants