ParamMatcher failed when using parameter with comma #467

Closed
opened 2025-12-29 15:24:30 +01:00 by adam · 16 comments
Owner

Originally created by @geovanegodoi on GitHub (Nov 24, 2022).

Originally assigned to: @StefH on GitHub.

Describe the bug

I'm working on a system that consumes a 3rd party API which accepts as querystring a SQL statement.
For example, to query some data from any table just build the URI like this:

  • http://host/api/queryservice?query=SELECT id FROM table WHERE id = 1
    While trying to mock this API, I realized that whenever I tried to mock a statement using comma, the ParamMatcher fails.
    For example, SELECT id, value FROM table WHERE id = 1.
    And I received a 404 (NotFound) error code.

Expected behavior:

I expected the ParamMatcher has succeded, and returned 200 (OK).

Test to reproduce

1 - Create an API which receives as querystring a SQL statement
2 - Mock that API using "WithParam" function
3 - Test creating a statement which has a 'comma' within, "SELECT id, value FROM table WHERE id = 1"

Provide additional information if any.

Originally created by @geovanegodoi on GitHub (Nov 24, 2022). Originally assigned to: @StefH on GitHub. ### Describe the bug I'm working on a system that consumes a 3rd party API which accepts as querystring a SQL statement. For example, to query some data from any table just build the URI like this: - `http://host/api/queryservice?query=SELECT id FROM table WHERE id = 1` While trying to mock this API, I realized that whenever I tried to mock a statement using comma, the ParamMatcher fails. For example, `SELECT id, value FROM table WHERE id = 1`. And I received a 404 (NotFound) error code. ### Expected behavior: I expected the ParamMatcher has succeded, and returned 200 (OK). ### Test to reproduce 1 - Create an API which receives as querystring a SQL statement 2 - Mock that API using "WithParam" function 3 - Test creating a statement which has a 'comma' within, "SELECT id, value FROM table WHERE id = 1" ### Other related info Provide additional information if any.
adam added the question label 2025-12-29 15:24:30 +01:00
adam closed this issue 2025-12-29 15:24:31 +01:00
Author
Owner

@StefH commented on GitHub (Nov 24, 2022):

What you can try:

1️⃣
url-escape the comma

2️⃣
Set https://github.com/WireMock-Net/WireMock.Net/blob/master/src/WireMock.Net/Settings/WireMockServerSettings.cs#L267 to QueryParameterMultipleValueSupport.NoComma

@StefH commented on GitHub (Nov 24, 2022): What you can try: :one: url-escape the comma :two: Set https://github.com/WireMock-Net/WireMock.Net/blob/master/src/WireMock.Net/Settings/WireMockServerSettings.cs#L267 to `QueryParameterMultipleValueSupport.NoComma`
Author
Owner

@geovanegodoi commented on GitHub (Nov 24, 2022):

Thanks for reply,

I've downloaded the latest nuget version (1.5.10) but there isn't this property.

image

Am I doing something wrong?

@geovanegodoi commented on GitHub (Nov 24, 2022): Thanks for reply, I've downloaded the latest nuget version (1.5.10) but there isn't this property. ![image](https://user-images.githubusercontent.com/35941336/203852552-14a9a4c5-e735-4ce0-97c9-68d0122e6de8.png) Am I doing something wrong?
Author
Owner

@StefH commented on GitHub (Nov 24, 2022):

No. Nothing is wrong on your end

I just realized that I need to release a new version which includes this.

I'll do that now.

@StefH commented on GitHub (Nov 24, 2022): No. Nothing is wrong on your end I just realized that I need to release a new version which includes this. I'll do that now.
Author
Owner

@geovanegodoi commented on GitHub (Nov 24, 2022):

Thanks, @StefH

I've just downloaded the new release, and now the property is ok.

When you said "url-escape the comma", could you show an example?

I tried somethings, but I still got the error.

@geovanegodoi commented on GitHub (Nov 24, 2022): Thanks, @StefH I've just downloaded the new release, and now the property is ok. When you said "url-escape the comma", could you show an example? I tried somethings, but I still got the error.
Author
Owner

@StefH commented on GitHub (Nov 25, 2022):

It could be that Url escaping does indeed nor work.

Then you need to use option 2.

Can this issue be closed?

@StefH commented on GitHub (Nov 25, 2022): It could be that Url escaping does indeed nor work. Then you need to use option 2. Can this issue be closed?
Author
Owner

@geovanegodoi commented on GitHub (Nov 25, 2022):

I'm still facing the issue.

The API I'm trying to mock is this one:
https://docs.oracle.com/en/cloud/saas/service/18a/cxsvc/op-services-rest-connect-v1.4-queryresults-get.html

It's a public Oracle REST API, to query entities from database.
When I try to mock this request I get a 404 error.
image

@geovanegodoi commented on GitHub (Nov 25, 2022): I'm still facing the issue. The API I'm trying to mock is this one: https://docs.oracle.com/en/cloud/saas/service/18a/cxsvc/op-services-rest-connect-v1.4-queryresults-get.html It's a public Oracle REST API, to query entities from database. When I try to mock this request I get a 404 error. ![image](https://user-images.githubusercontent.com/35941336/203974136-12a4861b-56e2-4f36-a681-1c362837b215.png)
Author
Owner

@StefH commented on GitHub (Nov 30, 2022):

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

@StefH commented on GitHub (Nov 30, 2022): https://github.com/WireMock-Net/WireMock.Net/pull/854
Author
Owner

@StefH commented on GitHub (Nov 30, 2022):

@gigiogodoi
Can you please provide a full working c# code example which simulates your issue? Because I cannot reproduce it using unit tests.

@StefH commented on GitHub (Nov 30, 2022): @gigiogodoi Can you please provide a full working c# code example which simulates your issue? Because I cannot reproduce it using unit tests.
Author
Owner

@geovanegodoi commented on GitHub (Nov 30, 2022):

@StefH
Follow an example repository to reproduce the error, using XUnit and .NET6 .

https://github.com/gigiogodoi/UnitTestWithWiremock

Inside it, there are 2 test cases, one failing because it is using a query with comma.

image

@geovanegodoi commented on GitHub (Nov 30, 2022): @StefH Follow an example repository to reproduce the error, using XUnit and .NET6 . https://github.com/gigiogodoi/UnitTestWithWiremock Inside it, there are 2 test cases, one failing because it is using a query with comma. ![image](https://user-images.githubusercontent.com/35941336/204792651-b67ed81f-6346-4874-8f36-cb4db0677336.png)
Author
Owner

@StefH commented on GitHub (Nov 30, 2022):

Thanks a lot for this unit test. I did find the issue and it's fixed in preview version 1.5.11-ci-16748.

@StefH commented on GitHub (Nov 30, 2022): Thanks a lot for this unit test. I did find the issue and it's fixed in preview version `1.5.11-ci-16748`.
Author
Owner

@geovanegodoi commented on GitHub (Nov 30, 2022):

@StefH
Could you add a testcase to validate a querystring like this ?

query=select id, name, value from table where id in (1, 2, 3, 4, 5)

@geovanegodoi commented on GitHub (Nov 30, 2022): @StefH Could you add a testcase to validate a querystring like this ? **query=select id, name, value from table where id in (1, 2, 3, 4, 5)**
Author
Owner
@StefH commented on GitHub (Nov 30, 2022): Yes. Works fine. https://github.com/WireMock-Net/WireMock.Net/blob/stef-849/test/WireMock.Net.Tests/WireMockServerTests.WithParam.cs
Author
Owner

@StefH commented on GitHub (Dec 2, 2022):

@gigiogodoi Is it ok?

@StefH commented on GitHub (Dec 2, 2022): @gigiogodoi Is it ok?
Author
Owner

@StefH commented on GitHub (Dec 3, 2022):

I'll merge the PR.

@StefH commented on GitHub (Dec 3, 2022): I'll merge the PR.
Author
Owner

@geovanegodoi commented on GitHub (Dec 3, 2022):

I was not able to download the preview version, because it was not releated in the nuget package manager.

But I will try once you release a new version.

@geovanegodoi commented on GitHub (Dec 3, 2022): I was not able to download the preview version, because it was not releated in the nuget package manager. But I will try once you release a new version.
Author
Owner

@StefH commented on GitHub (Dec 3, 2022):

previews are here: https://github.com/WireMock-Net/WireMock.Net/wiki/MyGet-preview-versions

But I'll release an official version today on nuget.

@StefH commented on GitHub (Dec 3, 2022): previews are here: https://github.com/WireMock-Net/WireMock.Net/wiki/MyGet-preview-versions But I'll release an official version today on nuget.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/WireMock.Net-wiremock#467