Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(message): use correct encodings for JSON Number values #281

Merged
merged 1 commit into from
Dec 2, 2024

Conversation

shellcromancer
Copy link
Contributor

Description

This updates the private setValue helper to conditonally use the correct float or integer encoding per JSON Number type. Relying on the gjson Value method can result in imprecise copies which caused incremented numbers on large integers like the test case added.

Motivation and Context

As shown in the added test cases bug caused consistent but imprecise copies where a writing a value such as 30400402455622563 would actually set the value of 30400402455622564.

How Has This Been Tested?

The new regression tests work, and this has fixed the observed imprecision in our internal deployment.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

@shellcromancer shellcromancer requested a review from a team as a code owner November 27, 2024 21:58
Copy link
Contributor

@jtan-brex jtan-brex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix looks good 👍 , can you add comments to the condition for clarification before merge?

This updates the private setValue helper to conditonally use the
correct float or integer encoding per JSON Number type. Relying on
the gjson Value method can result in imprecise copies which caused
incremented numbers on large integers like the test case added.
@shellcromancer shellcromancer force-pushed the dstinson-diess/fix/copy-large-ints branch from c76c9cc to 2ea570f Compare December 2, 2024 15:35
@shellcromancer shellcromancer merged commit d476fa5 into main Dec 2, 2024
6 checks passed
@shellcromancer shellcromancer deleted the dstinson-diess/fix/copy-large-ints branch December 2, 2024 15:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants