Skip to content

Precision loss in JSON matching #1169

Closed

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

Activity

  1. VintaChlenix commented on Jan 20, 2025

    @VintaChlenix
    ContributorAuthor
  2. added a commit that references this issue on Jan 20, 2025
  3. tommysitu commented on Jan 20, 2025

    @tommysitu
    Member

    Thanks for the quick fix. I will get a release out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

      ⌂ 换网址