Skip to content

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

Closed

Description

@Bafyn

Summary

When a request-parameter matcher is configured with a value and MatchBehaviour.RejectOnMatch, the result is inverted: a request whose parameter value equals the reject value matches the mapping (it should be rejected), and a request with a different value does not match (it should be accepted).

Steps to reproduce

var server = WireMockServer.Start();

// "Match this mapping only when query param 'k' is NOT 'abc'."
server
    .Given(Request.Create()
        .UsingGet()
        .WithPath("/x")
        .WithParam("k", MatchBehaviour.RejectOnMatch, "abc"))
    .RespondWith(Response.Create().WithSuccess());

var client = server.CreateClient();

// 'k=abc' equals the reject value => should be REJECTED (404), but returns 200.
var matches = await client.GetAsync($"http://localhost:{server.Port}/x?k=abc");
Console.WriteLine(matches.StatusCode); // Actual: OK (200)   Expected: NotFound (404)

// 'k=xyz' does not equal the reject value => should be ACCEPTED (200), but returns 404.
var notMatches = await client.GetAsync($"http://localhost:{server.Port}/x?k=xyz");
Console.WriteLine(notMatches.StatusCode); // Actual: NotFound (404)   Expected: OK (200)

server.Stop();

Expected vs actual

Request Expected Actual
GET /x?k=abc 404 (rejected) 200 (matched)
GET /x?k=xyz 200 (accepted) 404 (not matched)

AcceptOnMatch (the default) is unaffected and works correctly.

Activity

  1. added a commit that references this issue on Aug 11, 2026
    ab0825f
  2. added a commit that references this issue on Aug 13, 2026
    a0df091
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions