Skip to content

Precision loss in JSON matching #1169

@VintaChlenix

Description

@VintaChlenix

Description of the bug

In the process of comparison of JSONs there is a bug caused by unmarshaling json to interface{}. By default numbers parse to float64. It has 53 bits of mantissa. This causes to precision loss.

Steps to reproduce the issue

Real example:

Add a request json with bigint field to Hoverfly. For example {"id":1236546565217899832645}.
Then try to send a request with an id different from added by the last number. For example {"id":1236546565217899832640}.
Hoverfly will miss the difference.

Simple example:

Write a testcase in json or json partial matcher with the same JSONs.

Observed result

Image

Expected result

Matchers can find the difference between two JSONS with bigint fields.

Additional relevant information

  1. Hoverfly version: latest
  2. Anything that might help us to diagnose the problem

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions