Repository navigation
Conversation
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Integer map keys still parse native values with a 64-bit limit and can silently wrap on 32-bit targets.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 2
Open (2)
What changed in this PR
Updates integer decoding to respect the destination type’s native width.
Changes:
- Uses
v.Type().Bits()for native integer parsing. - Adds 32-bit overflow and boundary regression tests.
| File | Description |
|---|---|
decoder.go |
Applies native-width parsing to scalar integer fields. |
decoder_test.go |
Adds native integer overflow and boundary tests. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| } | ||
| var u64 uint64 | ||
| if u64, err = strconv.ParseUint(arr[idx], 10, 64); err != nil { | ||
| if u64, err = strconv.ParseUint(arr[idx], 10, v.Type().Bits()); err != nil { |
| } | ||
| var i64 int64 | ||
| if i64, err = strconv.ParseInt(arr[idx], 10, 64); err != nil { | ||
| if i64, err = strconv.ParseInt(arr[idx], 10, v.Type().Bits()); err != nil { |
Contributor
|
@vitalivo if you can address the above 🙏 I'll look at merging |
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.

This replaces #78, which was accidentally closed and its source fork deleted. The implementation is unchanged; the original discussion and reviews remain linked there.
Fixes Or Enhances
On 32-bit targets, decoding
2147483648intointsucceeds with-2147483648, and decoding4294967296intouintsucceeds with zero. The shared int/int64 and uint/uint64 branches always parse with a 64-bit limit before reflection truncates the value.Use the destination type's bit width for parsing. Regression tests verify both signed overflow directions, unsigned overflow, unchanged destination values on error, valid native boundaries, and values that still fit explicit 64-bit fields.
Validation: the three overflow cases fail on linux/386 before the fix. Full suites pass with
GOARCH=386 go test -cover ./...andgo test -race -cover ./...on amd64 (99.8% coverage).go vet ./...passes and golangci-lint reports no new issues.