mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-11 21:10:32 +01:00
NullRef using JsonPath.SelectToken #353
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @sethsouthern on GitHub (Jul 27, 2021).
Describe the bug
When using the JsonPath.SelectToken feature in the handlebar transformer, I get a null ref exception. The exception occurs in HandlebarsDotNet.Helpers.JsonPathHelpers.SelectToken(object, string). Decompiling shows that the value of the string parameter is
"name\"including the backslash. If I remove the backslash then everything works but the backslash is just the escape character for the double-quote. if this is the good old ID10T or pebcak issue, then please close. My guess is it's an off-by-one in some string parsing.Expected behavior:
Handlebar transformation should function as described in example at https://github.com/WireMock-Net/WireMock.Net/wiki/Response-Templating#jsonpath.
Test to reproduce
ParseAsJToken(value, "SelectToken").SelectToken("name")- evaluates correctlyParseAsJToken(value, "SelectToken").SelectToken("name\")- evaluates to nullOther related info
Unit Test Class
response.json
@StefH commented on GitHub (Jul 30, 2021):
Hello @sethsouthern.
WireMock.Net uses HandlebarsDotNet.Helpers.JsonPathHelpers to handle JsonPath. This project is located here:
https://github.com/Handlebars-Net/Handlebars.Net.Helpers
I did move the issue.
And can you please create a failing unit test ?
I want to check if this is an issue in JsonPath, JsonPathHelpers or Handlebars.Net