Jonathan Pink
05/19/2025, 11:51 AMabsent
feature with matchesJsonPath
when attempting to filter request logs.
I'll explain below 👍
if I check equality of the $.entitlementId
alone returns 1 request.
Request:
POST /requests/count
{
"method": "POST",
"urlPathPattern": "/merchant-entitlement/ns/804c2d9f-3689-4095-8403-fd0525fb834b/entitlements",
"bodyPatterns": [
{
"matchesJsonPath": {
"expression": "$.entitlementId",
"equalTo": "e331678d-160a-4530-a966-57341666b0b2"
}
}
]
}
Response: 200 OK
{
"count": 1,
"requestJournalDisabled": false
}
So this is evidence that the property appears in the log and is equal.
if I switch it to use absent
My expectation is that this will check if the field itself exists - so I perform the following request:
POST /requests/count
{
"method": "POST",
"urlPathPattern": "/merchant-entitlement/ns/804c2d9f-3689-4095-8403-fd0525fb834b/entitlements",
"bodyPatterns": [
{
"matchesJsonPath": {
"expression": "$.entitlementId",
"absent": false
}
}
]
}
Response: 200 OK
{
"count": 0,
"requestJournalDisabled": false
}
My thinking here that I am checking to ensure the property exists - which it does since the request first request for field equality returns a count of 1.
If I change the above request to "absent":"true"
I would expect it to return the above response like it does e.g "count":0
.
I've tried looking for more information about how absent
works but haven't been able to locate it so I'm hoping someone here can support 🙏 thank you
Further note: before I went down a bit of a rabbit hole here - my core requirement was to use this endpoint to ensure fields in requests do not exist
e.g.
entitlementId == xyz && otherFields does not exist
I'm unsure if this is possible, and if not - is there another way?
wiremock server - docker - wiremock:3.4.1-2Tom
05/19/2025, 2:58 PM{
"method": "POST",
"urlPathPattern": "/merchant-entitlement/ns/804c2d9f-3689-4095-8403-fd0525fb834b/entitlements",
"bodyPatterns": [
{
"matchesJsonPath": {
"expression": "$.entitlementId",
"not": {
"absent": true
}
}
}
]
}
Jonathan Pink
05/19/2025, 2:59 PMTom
05/19/2025, 3:00 PMTom
05/19/2025, 3:00 PMand
and or
, both of which are documented: https://wiremock.org/docs/request-matching/#logical-and-and-orJonathan Pink
05/19/2025, 3:01 PMTom
05/19/2025, 3:01 PMTom
05/19/2025, 4:20 PMJonathan Pink
05/20/2025, 8:03 AM"bodyPatterns": [
{
"matchesJsonPath": {
"expression": "$.entitlementId",
"not": {
"absent": false
}
}
}
]
absent to true
and false
continues to return
{
"count": 1,
"requestJournalDisabled": false
}
in both cases 🤷
I'd expect:
• not absent: true
would ensure it exists
• not absent: false
would ensure it doesn't exist.
But I'm not seeing any differentiation on the responseTom
05/20/2025, 8:13 AMLee Turner
05/20/2025, 8:14 AMJonathan Pink
05/20/2025, 8:39 AMTom
05/20/2025, 9:45 AMJonathan Pink
05/20/2025, 9:50 AM$.entitlementId
using equalTo
- the count returns as 1
so i can confirm it exists.
I have tried using:
{
"matchesJsonPath": {
"expression": "$.entitlementId",
"absent": false/true
}
}
And both return a count of 0
I would expect the request to /requests/count
to return 1 in this case:
{
"matchesJsonPath": {
"expression": "$.entitlementId",
"not": {
"absent": true
}
}
}
But it returns a count of 0
Tom
05/20/2025, 11:16 AMJonathan Pink
05/20/2025, 1:07 PMJonathan Pink
05/20/2025, 1:08 PMdocker run -it --rm \
-p 8080:8080 \
--name wiremock \
wiremock/wiremock:3.4.1-2
Tom
05/20/2025, 4:42 PMJonathan Pink
05/21/2025, 7:02 AMJonathan Pink
05/22/2025, 6:26 AMTom
05/22/2025, 3:26 PM"matchesJsonPath": {
"expression": "$.entitlementId",
"absent": true
}
And with this I get 1:
"matchesJsonPath": {
"expression": "$.entitlementId",
"not": {
"absent": true
}
}
Jonathan Pink
05/23/2025, 6:59 AM__admin/requests/count
And i'm expecting toggling absent to true and false to yield different results, however they are the same.Tom
05/23/2025, 9:39 AMnot
does the equivalent of "absent": false
. Is there any reason you can’t do that?Jonathan Pink
05/23/2025, 9:41 AM