SpectoLabs / hoverfly

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

Invalid data when using template #1107

Closed vuklip closed 10 months ago

vuklip commented 11 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 11 months ago

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

vuklip commented 11 months ago

Nice, thx! Waiting for version 1.6.2 :)

tommysitu commented 10 months ago

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