SpectoLabs / hoverfly

Lightweight service virtualization/ API simulation / API mocking tool for developers and testers
https://hoverfly.io
Apache License 2.0
2.33k stars 204 forks source link

Invalid data when using template #1107

Closed vuklip closed 6 months ago

vuklip commented 6 months ago

Description of the bug

Invalid getting value by template. Let me explain.

Steps to reproduce the issue

I have this simulation:

{
    "data": {
        "pairs": [
            {
                "request": {
                    ...
                },
                "response": {
                    "status": 200,
                    "body": "{ "id": "{{ Request.Body 'jsonpath' '$.params.otp.id' }}" }",
                    "encodedBody": false,
                    "headers": {
                        "Content-Type": [
                            "application/json"
                        ]
                    },
                    "templated": true
                }
            }
        ],
       ...
}

and I send the request like

{"params":{"otp":{"id":998974625887}}}

Observed result

{"id": "9.98974625887e+11"}

If possible, add screenshots to help explain your problem

Expected result

{"id": "998974625887"}

Additional relevant information

  1. Hoverfly version: 1.6.1 and older. I also tested with 1.3.6.
  2. Anything that might help us to diagnose the problem
tommysitu commented 6 months ago

@vuklip I did notice this bug recently as well, I will merge my fix soon.

vuklip commented 6 months ago

Nice, thx! Waiting for version 1.6.2 :)

tommysitu commented 6 months ago

fixed in https://github.com/SpectoLabs/hoverfly/releases/tag/v1.6.2