Skip to content

test(reconcile): guard canonicalJSON number precision with a 2^53 pair - #1884

Merged
rohilsurana merged 1 commit into
mainfrom
fix/reconcile-metaschema-number-precision-test
Aug 14, 2026
Merged

test(reconcile): guard canonicalJSON number precision with a 2^53 pair#1884
rohilsurana merged 1 commit into
mainfrom
fix/reconcile-metaschema-number-precision-test

Conversation

@rohilsurana

Copy link
Copy Markdown
Member

Summary

Fixes the TestCanonicalJSON large-integer case so it actually guards the UseNumber decode in canonicalJSON.

The problem

The test compared 10000000000000001 and 10000000000000002. Under the old float64 decode those round to 10000000000000000 and 10000000000000002, which already differ, so the test passed even without the fix. Reverting decodeJSON to json.Unmarshal left the test green, so it caught nothing.

The fix

Use the 2^53 pair instead: 9007199254740993 and 9007199254740992 both round to 9007199254740992 under float64, so they compare equal on the old code. The test now fails without UseNumber and passes with it.

Test Plan

  • With UseNumber (current code) the test passes.
  • Dropping dec.UseNumber() makes it fail (both inputs canonicalize to 9007199254740992).
  • Restoring UseNumber passes again.
  • go build ./... and gofmt clean.

@vercel

vercel Bot commented Aug 14, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
frontier Ready Ready Preview Aug 14, 2026 8:39am

@coderabbitai

coderabbitai Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 171b2f17-0be7-4a9d-a178-888fd042444a

📥 Commits

Reviewing files that changed from the base of the PR and between 059f974 and 25fa914.

📒 Files selected for processing (1)
  • internal/reconcile/metaschema_test.go

📝 Walkthrough

Summary by CodeRabbit

  • Tests
    • Improved coverage for JSON number handling at IEEE-754 precision boundaries.
    • Added validation that preserves values around the 2^53 floating-point limit.

Walkthrough

The canonical JSON precision test now uses 9007199254740993 and 9007199254740992. Comments explain that float64 decoding would collapse the larger value into the smaller value.

Changes

JSON Precision Test

Layer / File(s) Summary
IEEE-754 boundary validation
internal/reconcile/metaschema_test.go
The test uses adjacent values at the float64 precision boundary and documents the expected rounding issue.

Estimated code review effort: 1 (Trivial) | ~3 minutes

Merge Risk: ⚪ Minimal · up to 25fa9

This test-only change strengthens protection against JSON number-precision regressions without changing production behavior; no actionable merge-blocking risk remains.

🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@rohilsurana
rohilsurana marked this pull request as ready for review August 14, 2026 08:39
@coveralls

Copy link
Copy Markdown

Coverage Report for CI Build 31784755875

Warning

Build has drifted: This PR's base is out of sync with its target branch, so coverage data may include unrelated changes.
Quick fix: rebase this PR. Learn more →

Coverage remained the same at 48.641%

Details

  • Coverage remained the same as the base build.
  • Patch coverage: No coverable lines changed in this PR.
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 40032
Covered Lines: 19472
Line Coverage: 48.64%
Coverage Strength: 15.67 hits per line

💛 - Coveralls

@rohilsurana
rohilsurana merged commit 7c10c55 into main Aug 14, 2026
8 checks passed
@rohilsurana
rohilsurana deleted the fix/reconcile-metaschema-number-precision-test branch August 14, 2026 08:56
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.

3 participants