WireMock.Net TestContainer - Docker Logs contain Template references a helper that cannot be resolved. Helper Linq, only on Github Action #665

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

Originally created by @epDugas on GitHub (Jan 23, 2025).

Originally assigned to: @epDugas on GitHub.

Using WireMock TestContainers.
I have an integration test that is only failing when executed during a Github Action. I do not experience this issue locally. The docker log message that is related to the test failure is:

Template references a helper that cannot be resolved. Helper \u0027Linq\u0027

The handlebar template string I am using is:

"{{Linq request.bodyAsJson 'it.requests.Count()'}}"

The github test runner OS is:
Ubuntu
24.04.1

This test was working as of yesterday during the Github Workflow, and seems to have broke suddenly.
Any help/guidance would be greatly appreciated.

Originally created by @epDugas on GitHub (Jan 23, 2025). Originally assigned to: @epDugas on GitHub. Using WireMock TestContainers. I have an integration test that is only failing when executed during a Github Action. I do not experience this issue locally. The docker log message that is related to the test failure is: `Template references a helper that cannot be resolved. Helper \u0027Linq\u0027` The handlebar template string I am using is: `"{{Linq request.bodyAsJson 'it.requests.Count()'}}"` The github test runner OS is: Ubuntu 24.04.1 This test was working as of yesterday during the Github Workflow, and seems to have broke suddenly. Any help/guidance would be greatly appreciated.
adam added the question label 2025-12-29 15:30:17 +01:00
adam closed this issue 2025-12-29 15:30:17 +01:00
Author
Owner

@epDugas commented on GitHub (Jan 23, 2025):

Apologies, I should have reviewed recent releases. I see that dynamic linq was disabled. Request suggestion to achieve the same as the above.

"{{Linq request.bodyAsJson 'it.requests.Count()'}}"

which is to get the count of a json array contained in a property named "requests" in the request.bodyAsJson.

@epDugas commented on GitHub (Jan 23, 2025): Apologies, I should have reviewed recent releases. I see that dynamic linq was disabled. Request suggestion to achieve the same as the above. `"{{Linq request.bodyAsJson 'it.requests.Count()'}}"` which is to get the count of a json array contained in a property named "requests" in the request.bodyAsJson.
Author
Owner

@epDugas commented on GitHub (Jan 25, 2025):

I submitted a PR at Handlebars.Net.Helpers to add an Enumerable.Count helper.
I looked at adding a custom helper with HandlebarsRegistrationCallback, but did not see a "hook" to add this to the WireMock.Net TestContainer. builder.

@epDugas commented on GitHub (Jan 25, 2025): I submitted a PR at `Handlebars.Net.Helpers` to add an `Enumerable.Count` helper. I looked at adding a custom helper with `HandlebarsRegistrationCallback`, but did not see a "hook" to add this to the WireMock.Net TestContainer. builder.
Author
Owner

@StefH commented on GitHub (Jan 25, 2025):

@epDugas
Thank you. I left a review comment at, https://github.com/Handlebars-Net/Handlebars.Net.Helpers/pull/113.
Can you take a look?

@StefH commented on GitHub (Jan 25, 2025): @epDugas Thank you. I left a review comment at, https://github.com/Handlebars-Net/Handlebars.Net.Helpers/pull/113. Can you take a look?
Author
Owner

@StefH commented on GitHub (Jan 26, 2025):

BTW I was thinking, can't you use the length ?

In handlebars.js, this does seem tot work:
https://handlebarsjs.com/playground.html

Image

@StefH commented on GitHub (Jan 26, 2025): BTW I was thinking, can't you use the `length` ? In handlebars.js, this does seem tot work: https://handlebarsjs.com/playground.html ![Image](https://github.com/user-attachments/assets/369d63df-2eb9-4b6a-8234-b0d895f613be)
Author
Owner

@StefH commented on GitHub (Jan 26, 2025):

Also works in Handlebars.Net
https://github.com/Handlebars-Net/Handlebars.Net.Helpers/blob/master/examples/ConsoleApp/Program.cs#L167

Image

@StefH commented on GitHub (Jan 26, 2025): Also works in Handlebars.Net https://github.com/Handlebars-Net/Handlebars.Net.Helpers/blob/master/examples/ConsoleApp/Program.cs#L167 ![Image](https://github.com/user-attachments/assets/5a378645-3bc0-47d8-85c7-06634022be11)
Author
Owner

@StefH commented on GitHub (Jan 26, 2025):

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

@StefH commented on GitHub (Jan 26, 2025): https://github.com/WireMock-Net/WireMock.Net/pull/1245
Author
Owner

@epDugas commented on GitHub (Jan 26, 2025):

Thanks @StefH . I tried various things and didn't have any luck. Just tried the following template string again just to verify, and didn't have any luck (the result was null). Just some additional info, I am using this in a static mapping file:

{{request.bodyAsJson.requests.length}}

Request:

"BodyAsJson": {
  "requests": [
    {
      "code": "3881",
      "value": "updatedValue"
    }
   ]
},
@epDugas commented on GitHub (Jan 26, 2025): Thanks @StefH . I tried various things and didn't have any luck. Just tried the following template string again just to verify, and didn't have any luck (the result was null). Just some additional info, I am using this in a static mapping file: `{{request.bodyAsJson.requests.length}}` Request: ``` "BodyAsJson": { "requests": [ { "code": "3881", "value": "updatedValue" } ] }, ```
Author
Owner

@StefH commented on GitHub (Jan 27, 2025):

I've just released NuGet 1.7.1 which includes your handlebars update.

And later today, I'll also release new Docker version.

@StefH commented on GitHub (Jan 27, 2025): I've just released NuGet 1.7.1 which includes your handlebars update. And later today, I'll also release new Docker version.
Author
Owner

@StefH commented on GitHub (Jan 27, 2025):

Docker images 1.7.1 are available.

@StefH commented on GitHub (Jan 27, 2025): Docker images 1.7.1 are available.
Author
Owner

@epDugas commented on GitHub (Jan 27, 2025):

Confirmed, closing.

@epDugas commented on GitHub (Jan 27, 2025): Confirmed, closing.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/WireMock.Net-wiremock#665