fix(validation): correct int-width bound in GetIntFromInterface#538
Merged
Conversation
Comparing a float64 against math.MaxInt directly wrongly rejects the true max int on platforms where MaxInt fits exactly in a float64 (float64(MaxInt) only rounds up to 2^63 when int is 64 bits). Add 1 to get the correct exclusive upper bound on either width, and derive the boundary tests from math.MaxInt instead of a hardcoded 2^63 so they stay in range regardless of platform int width.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #538 +/- ##
==========================================
+ Coverage 78.57% 78.58% +0.01%
==========================================
Files 192 192
Lines 18522 18522
==========================================
+ Hits 14553 14555 +2
+ Misses 2904 2902 -2
Partials 1065 1065
🚀 New features to boost your workflow:
|
Phil-Browne
added a commit
that referenced
this pull request
Jul 11, 2026
The GetIntFromInterface int-width bound fix and the interactive tag-editing empty-value fix are orthogonal to the prompt/validator parity work here, so they were pulled into their own PRs: - GetIntFromInterface overflow bound -> #538 - interactive tag-edit empty-value handling -> #539 Restores those six files to the main baseline; this PR now stays focused on partner-config and prefix-filter validation parity.
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a platform-dependent overflow check in internal/validation.GetIntFromInterface when converting JSON-derived float64 values to int, ensuring correct behavior across 32-bit (including js/wasm) and 64-bit int targets.
Changes:
- Adjusts the float64→int upper-bound validation to use an exclusive bound (
v >= float64(math.MaxInt)+1) to avoidfloat64(math.MaxInt)rounding pitfalls. - Updates unit tests to use
math.MaxInt-derived boundary values (instead of hardcoded2^63) for platform portability.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| internal/validation/conversion.go | Updates float64 range validation logic to correctly reject out-of-range values regardless of int width / float64 rounding behavior. |
| internal/validation/conversion_test.go | Extends test coverage around the upper-bound behavior using math.MaxInt-derived values. |
penzeliz-megaport
approved these changes
Jul 13, 2026
penzeliz-megaport
left a comment
Collaborator
There was a problem hiding this comment.
Reviewed for correctness; no findings. LGTM.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Extracted from #535 (ESD-1648) as a standalone fix, orthogonal to the prompt/validator-parity work in that PR.
GetIntFromInterfacecompared a JSON-derivedfloat64againstmath.MaxIntdirectly.float64(math.MaxInt)rounds up to 2^63 only whenintis 64 bits, so on platforms whereMaxIntfits exactly in a float64 (e.g. 32-bitint, js/wasm) the check wrongly rejected the true max int.>= float64(math.MaxInt)+1as the exclusive upper bound, correct on either int width.math.MaxIntinstead of a hardcoded 2^63 so they stay in range on any platform.