question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

WireMock evaluation of all criteria generates unnecessary warnings

See original GitHub issue

[Description] Short version: Non-json requests are evaluated against json mappings with body patterns and fill the log with failed json validation warnings. Longer version: Because WireMock does an aggregation of the results for all evaluation rules (RequestPattern.match(Request request)) instead of hierarchically allowing a subsequent criterion to be evaluated against only after the higher one was matched, mappings that would immediately be excluded based on things like URL are still evaluated for body pattern matches. This is an issue when json body pattern matching mappings exists because it tries to evaluate ALL requests [that did not previously match] against the json body pattern matching mappings, which fills the log with all kind of json validation warnings.

[Repro]

  1. Start WireMock.
  2. Train WireMock [use something like Postman and POST to WireMockServer:WireMockPort/__admin/mappings/] with RAW body:

{ "id": "fab6d56b-d66e-4a5a-810a-ab323e485103", "request": { "urlPath": "/unavailablepath", "method": "POST", "headers": { "X-SessionId": { "equalTo": "90930D577144AB198B2082CA56E6A0F5", "caseInsensitive": true } }, "bodyPatterns": [ { "matchesJsonPath": "$.params[0][?(@.parameterone == 'something')]" } ] }, "response": { "status": 200, "bodyFileName": "a.json", "headers": { "Content-Type": "application/json" } }, "uuid": "fab6d56b-d66e-4a5a-810a-ab323e485103" }

  1. Make sure the a.json file exists. I do not believe its content is relevant, but when I was creating the repro for this bug this is what I put in mine:

{ "jsonrpc": "2.0", "id": "-1412417872994864924", "result": { "payload": { "timeStamp": "2017-02-17T16:26:28.588" } } }

  1. Send a non-admin request to WireMock. I used an empty GET to WireMockServer:WireMockPort/services/none
  2. Observe the WireMock console. Result contains something like (actual error differs based on body patterns in mappings and on the requests):

20:41:12 INFO WireMock - Warning: JSON path expression ‘$.params[0][?(@.parameterone == ‘something’)]’ failed to match document ‘’ because of error ‘json string can not be null or empty’ 20:41:12 INFO WireMock - Warning: JSON path expression ‘$.params[0][?(@.parameterone == ‘something’)]’ failed to match document ‘’ because of error ‘json string can not be null or empty’

The number of such entries considerably increases when the mappings are more complex and the requests are quite large. I think it is a one to one matching for each line of the request to each body pattern and each will generate at least a warning.

This makes our logs (which are already quite large) extremely large and it is very hard to follow what is wrong when you need to navigate through hundreds of pages of such warnings.

We also do not want to downgrade the logging level since we would like to be able to observe the [other] information provided.

[Environment]

We are using WireMock 2.5.1, but we tested (before actually debugging the code and finding the root cause) and the issue is still present in WireMock 2.8.0.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:4
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
nzCharliecommented, Oct 17, 2017

I think it is the same as this issue

0reactions
tomakehurstcommented, Apr 28, 2021

Closing individual logging issues in favour of (referenced) logging redesign issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

WireMock evaluation of all criteria generates unnecessary ...
This is an issue when json body pattern matching mappings exists because it tries to evaluate ALL requests [that did not previously match] ......
Read more >
Configuring WireMock in Java
Typically it is only necessary to tweak these settings if you are doing performance testing under significant loads. // Set the number of...
Read more >
OWASP Top 10 Security Vulnerabilities: How To Mitigate them
This is a complete guide to OWASP (Open Web Application Security Project ) Top 10 Security Vulnerabilities and guidelines to mitigate them.
Read more >
Playing With Spring Cloud Contract - DZone Performance
Now, with all the information to hand, it's time to put all those ... will allow the consumer to generate a WireMock (which...
Read more >
homebrew-core - Homebrew Formulae
a2ps 4.14 Any‑to‑PostScript filter aacgain 1.8 AAC‑supporting version of mp3gain aalib 1.4rc5 Portable ASCII art graphics library aamath 0.3 Renders mathematical expressions as ASCII art
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found