Response Body Does Not Include Text After Path Segment #651

Closed
opened 2025-12-29 15:29:42 +01:00 by adam · 1 comment
Owner

Originally created by @adambricelis on GitHub (Nov 19, 2024).

Originally assigned to: @StefH on GitHub.

Describe the bug

When a field in the response body is prefixed with a path segment from the request, the text after that path segment is not included in the response body.

Expected behavior:

WireMock should evaluate all of the text in the mapping and include all of it in the response.

Test to reproduce

Mapping:

[
  {
    "Request": {
      "Path": "/path",
      "Methods": [
        "GET"
      ]
    },
    "Response": {
      "StatusCode": 200,
      "BodyAsJson": {
        "field": "{{request.PathSegments.[0]}}text_being_removed_incorrectly"
      },
      "UseTransformer": true,
      "Headers": {
        "Content-Type": "application/json"
      }
    }
  }
]

Request: GET http://{WIREMOCK_SERVER_HOST}/path
Expected response:

{
  "field": "pathtext_being_removed_incorrectly"
}

Actual response:

{
  "field": "path"
}

This issue only occurs when the request path segment is the prefix of a field in the response body. Adding any characters before the request path segment resolves the issue.

Mapping:

[
  {
    "Request": {
      "Path": "/path",
      "Methods": [
        "GET"
      ]
    },
    "Response": {
      "StatusCode": 200,
      "BodyAsJson": {
        "field": "prefix{{request.PathSegments.[0]}}text_being_removed_incorrectly"
      },
      "UseTransformer": true,
      "Headers": {
        "Content-Type": "application/json"
      }
    }
  }
]

Request: GET http://{WIREMOCK_SERVER_HOST}/path
Response:

{
  "field": "prefixpathtext_being_removed_incorrectly"
}
Originally created by @adambricelis on GitHub (Nov 19, 2024). Originally assigned to: @StefH on GitHub. ### Describe the bug When a field in the response body is prefixed with a path segment from the request, the text after that path segment is not included in the response body. ### Expected behavior: WireMock should evaluate all of the text in the mapping and include all of it in the response. ### Test to reproduce Mapping: ``` [ { "Request": { "Path": "/path", "Methods": [ "GET" ] }, "Response": { "StatusCode": 200, "BodyAsJson": { "field": "{{request.PathSegments.[0]}}text_being_removed_incorrectly" }, "UseTransformer": true, "Headers": { "Content-Type": "application/json" } } } ] ``` Request: `GET http://{WIREMOCK_SERVER_HOST}/path` Expected response: ``` { "field": "pathtext_being_removed_incorrectly" } ``` Actual response: ``` { "field": "path" } ``` ### Other related info This issue only occurs when the request path segment is the prefix of a field in the response body. Adding any characters before the request path segment resolves the issue. Mapping: ``` [ { "Request": { "Path": "/path", "Methods": [ "GET" ] }, "Response": { "StatusCode": 200, "BodyAsJson": { "field": "prefix{{request.PathSegments.[0]}}text_being_removed_incorrectly" }, "UseTransformer": true, "Headers": { "Content-Type": "application/json" } } } ] ``` Request: `GET http://{WIREMOCK_SERVER_HOST}/path` Response: ``` { "field": "prefixpathtext_being_removed_incorrectly" } ```
adam added the bug label 2025-12-29 15:29:42 +01:00
adam closed this issue 2025-12-29 15:29:42 +01:00
Author
Owner

@StefH commented on GitHub (Nov 21, 2024):

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

@StefH commented on GitHub (Nov 21, 2024): https://github.com/WireMock-Net/WireMock.Net/pull/1213
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/WireMock.Net-wiremock#651