Admin API fails to create a mapping with Request Header matching using WildCardMatcher #628

Closed
opened 2025-12-29 15:29:18 +01:00 by adam · 3 comments
Owner

Originally created by @kaushiksk on GitHub (Sep 7, 2024).

Originally assigned to: @StefH on GitHub.

Describe the bug

When creating a mapping that contains wildcard match on a specific header, the mapping is not created, API returns 201.
The created mapping is not returned in GET __admin/mappings.

Expected behavior:

Header match mapping should appear when querying GET __admin/mappings.

Test to reproduce

POST /__admin/mappings

{
  "Guid": "419c3832-9fb6-4998-9a86-8edc57af65ff",
  "Title": "Header based routing",
  "Request": {
    "Headers": [
      {
        "Name": "myheader",
        "Matchers": [
          {
            "Name": "WildcardMatcher",
            "Pattern": "*aaaaaa*",
          }
        ],
      }
    ],
  },
  "Response": {
    "ProxyUrl": "http://localhost:9124",
  },
}

Response: 201 Created

{
  "Status": "Mapping added"
}

Get /__admin/mappings does not return this mapping.
I am able to get other mappings that are created on path etc. using WildCardMatcher.

Originally created by @kaushiksk on GitHub (Sep 7, 2024). Originally assigned to: @StefH on GitHub. ### Describe the bug When creating a mapping that contains wildcard match on a specific header, the mapping is not created, API returns 201. The created mapping is not returned in `GET __admin/mappings`. ### Expected behavior: Header match mapping should appear when querying `GET __admin/mappings`. ### Test to reproduce `POST /__admin/mappings` ```json { "Guid": "419c3832-9fb6-4998-9a86-8edc57af65ff", "Title": "Header based routing", "Request": { "Headers": [ { "Name": "myheader", "Matchers": [ { "Name": "WildcardMatcher", "Pattern": "*aaaaaa*", } ], } ], }, "Response": { "ProxyUrl": "http://localhost:9124", }, } ``` Response: `201 Created` ```json { "Status": "Mapping added" } ``` `Get /__admin/mappings` does not return this mapping. I am able to get other mappings that are created on path etc. using WildCardMatcher.
adam added the bug label 2025-12-29 15:29:18 +01:00
adam closed this issue 2025-12-29 15:29:19 +01:00
Author
Owner

@StefH commented on GitHub (Sep 8, 2024):

@kaushiksk
The reason is:
The Path or Url matcher is missing for this mapping, this mapping will not be added.

However I cannot remember anymore why I build it like this.... I need to check if there is a technical reason for this or a business reason...

@StefH commented on GitHub (Sep 8, 2024): @kaushiksk The reason is: _The Path or Url matcher is missing for this mapping, this mapping will not be added._ However I cannot remember anymore why I build it like this.... I need to check if there is a technical reason for this or a business reason...
Author
Owner

@kaushiksk commented on GitHub (Sep 8, 2024):

This works when I configure it directly in code as below:

mockServer
    .Given(Request.Create().WithHeader("myheader", new WildcardMatcher($"*aaaaaa*")))
    .WithTitle("Header based routing")
    .RespondWith(Response.Create().WithProxy(mockServerEndpoint));

With this mapping, the wiremock server is able to do exactly what I intend, I validated from logs that my requests are successfully being matched and proxied. In fact, this is how I figured out the exact payload to send to the POST /__admin/mappings API (I got it from Get /__admin/mappings once the server was running).

So it seems like something that is only missing in the Admin API?

@kaushiksk commented on GitHub (Sep 8, 2024): This works when I configure it directly in code as below: ```cs mockServer .Given(Request.Create().WithHeader("myheader", new WildcardMatcher($"*aaaaaa*"))) .WithTitle("Header based routing") .RespondWith(Response.Create().WithProxy(mockServerEndpoint)); ``` With this mapping, the wiremock server is able to do exactly what I intend, I validated from logs that my requests are successfully being matched and proxied. In fact, this is how I figured out the exact payload to send to the `POST /__admin/mappings` API (I got it from `Get /__admin/mappings` once the server was running). So it seems like something that is only missing in the Admin API?
Author
Owner

@StefH commented on GitHub (Sep 9, 2024):

https://github.com/WireMock-Net/WireMock.Net/pull/1169

@StefH commented on GitHub (Sep 9, 2024): https://github.com/WireMock-Net/WireMock.Net/pull/1169
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/WireMock.Net-wiremock#628