Skip to content

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

Merged
StefH merged 1 commit into
wiremock:masterfrom
Bafyn:fix/withparam-rejectonmatch-inverted
Aug 13, 2026
Merged

Fix WithParam RejectOnMatch inverting the match result #1496#1497
StefH merged 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
@StefH
StefH merged commit a0df091 into wiremock:master Aug 13, 2026
7 of 8 checks passed
@Bafyn
Bafyn deleted the fix/withparam-rejectonmatch-inverted branch August 13, 2026 18:59
This was referenced Aug 15, 2026
hangy pushed a commit to hangy/NLog.Targets.ApplicationInsights that referenced this pull request Sep 1, 2026
Updated [WireMock.Net](https://github.com/wiremock/WireMock.Net) from
2.13.0 to 2.15.0.

<details>
<summary>Release notes</summary>

_Sourced from [WireMock.Net's
releases](https://github.com/wiremock/WireMock.Net/releases)._

## 2.15.0

## What's Changed
* Fix #​1494: `WithClientIP(MatchOperator, params IStringMatcher[])`
ignores the MatchOperator argument by @​Bafyn in
wiremock/WireMock.Net#1495
* Fix WithParam RejectOnMatch inverting the match result #​1496 by
@​Bafyn in wiremock/WireMock.Net#1497
* Update Testcontainers by @​StefH in
wiremock/WireMock.Net#1499


**Full Changelog**:
wiremock/WireMock.Net@2.14.0...2.15.0

## 2.14.0

## What's Changed
* Fix #​1492: Serialize WithClientIP matcher to Request.ClientIP by
@​Bafyn in wiremock/WireMock.Net#1493

## New Contributors
* @​Bafyn made their first contribution in
wiremock/WireMock.Net#1493

**Full Changelog**:
wiremock/WireMock.Net@2.13.0...2.14.0

Commits viewable in [compare
view](wiremock/WireMock.Net@2.13.0...2.15.0).
</details>

[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=WireMock.Net&package-manager=nuget&previous-version=2.13.0&new-version=2.15.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
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