fix: remove go-safecast dependency - #738
Conversation
|
|
Walkthrough
ChangesTuple import validation
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
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. Comment |
1a98482 to
3fe6922
Compare
There was a problem hiding this comment.
Pull request overview
Removes the github.com/rung/go-safecast dependency by replacing safecast.Int32() conversions with explicit upper-bound checks before casting to int32, and adds tests to cover the new validation behavior.
Changes:
- Replaced
safecast.Int32(...)calls withmath.MaxInt32bounds checks and directint32(...)casts. - Removed
go-safecastfromgo.mod,go.sum, and.golangci.yamlallowlist/dep configuration. - Added a unit test to ensure values exceeding the
int32range are rejected.
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/tuple/import.go | Removes go-safecast usage and adds explicit math.MaxInt32 checks before int32 casting. |
| internal/tuple/import_test.go | Adds coverage for rejecting values that exceed int32 bounds. |
| go.mod | Drops the github.com/rung/go-safecast dependency requirement. |
| go.sum | Removes go-safecast checksum entries. |
| .golangci.yaml | Removes go-safecast from the dependency allowlist/config. |
Suppressed comments (1)
internal/tuple/import_test.go:38
- This test hard-codes the numeric value of math.MaxInt32 in the expected error string. Using
math.MaxInt32directly (formatted via strconv) would keep the test aligned with the production error message and avoid a magic number.
expectedError: "maxParallelRequests must be at most 2147483647",
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
3fe6922 to
efa7051
Compare
efa7051 to
e82ad2b
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 5 changed files in this pull request and generated 1 comment.
Suppressed comments (2)
internal/tuple/import_test.go:33
- Avoid hard-coding
2147483647in the expected error string; building it frommath.MaxInt32keeps the test aligned with the production error message if it changes.
}{
{
name: "max tuples per write",
maxTuplesPerWrite: maxInt32PlusOne,
maxParallelRequests: 1,
expectedError: "maxTuplesPerWrite must be at most " + maxInt32,
internal/tuple/import_test.go:39
- Same as above: derive the expected max value from
math.MaxInt32instead of duplicating the literal, to keep the test resilient to message changes.
},
{
name: "max parallel requests",
maxTuplesPerWrite: 1,
maxParallelRequests: maxInt32PlusOne,
expectedError: "maxParallelRequests must be at most " + maxInt32,
e82ad2b to
9316192
Compare
|
Addressed the 32-bit compilation comment in |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 5 changed files in this pull request and generated no new comments.
Suppressed comments (1)
internal/tuple/import_test.go:48
- The subtests run in parallel, but the range variable
testis captured by the closure. This can cause flaky failures / wrong inputs becausetestis reused across iterations. Create a per-iteration copy before starting the parallel subtest.
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
t.Parallel()
Summary
go-safecastconversions with explicitmath.MaxInt32bounds checks in shared import-parameter validationgo-safecastfrom module and lint configurationint32range, including 32-bit compilation behaviorFixes #672
Testing
go mod verifygo test ./...GOARCH=386 go test ./internal/tuple -run TestImportTuplesRejectsValuesOutsideInt32Range -count=1Summary by CodeRabbit
Bug Fixes
Tests