Updates int32 to int#55
Conversation
… simplify path variable parsing logic.
…int32` for IDs, align tests, request structs, and SQLC-generated files.
…uding SQLC-generated files, interfaces, tests, request structs, and related methods.
📝 WalkthroughWalkthroughThis PR implements the type migration from PostgreSQL ChangesPostgreSQL int4 to Go int Type Migration
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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 |
|
@coderabitai review |
|
@CodeRabbit review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
internal/path_variable_validator_test.go (1)
59-102:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winAdd unit test for int32/int4 overflow boundary.
The test file lacks coverage for values exceeding
math.MaxInt32(2147483647). With the recent change fromint32tointin the function signature,GetIntFromRequestPathnow accepts values like "2147483648" viastrconv.Atoi, which would pass to PostgreSQL int4 columns and fail at the database layer instead of being rejected cleanly at validation.Add a test case to ensure int4 overflow is caught at validation time:
Suggested test case
+ { + name: "Int4 overflow ID", + varName: "id", + pathVal: "2147483648", // math.MaxInt32 + 1; valid int64 but exceeds PostgreSQL int4 + want: 0, + wantOk: false, + },🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@internal/path_variable_validator_test.go` around lines 59 - 102, Test suite for GetIntFromRequestPath is missing a case for int32/int4 overflow; add a new table test entry in TestGetIntFromRequestPath (internal/path_variable_validator_test.go) with varName "id", pathVal "2147483648" (or math.MaxInt32+1 as string), want 0 and wantOk false to assert overflow is rejected by validation rather than accepted by strconv.Atoi; update the test table alongside the existing cases so the function GetIntFromRequestPath is exercised for values > math.MaxInt32.
🧹 Nitpick comments (1)
internal/product/handler_test.go (1)
145-240: ⚡ Quick winAdd large-ID boundary test cases for the int migration paths.
These suites validate non-numeric/zero/negative IDs, but they don’t cover oversized positive IDs (e.g.,
2147483648) foridandplatform_id. Adding those cases would close a key regression gap from theint32→intchange.As per coding guidelines,
**/*_test.go: "Assess the unit test code assessing sufficient code coverage for the changes associated in the pull request".Also applies to: 242-326, 328-399, 401-569
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@internal/product/handler_test.go` around lines 145 - 240, Add unit tests for oversized positive IDs to TestDeleteProduct to cover int boundary/regression from int32→int; specifically add cases where id is "2147483648" (and similarly for platform_id in other test suites) and ensure mockProductQuerier.deleteProductFunc handles or rejects those values (e.g., by not being called or returning an appropriate error), then assert the handler (productHandler.DeleteProduct) returns http.StatusBadRequest or the expected error status; update the tests at the referenced suites (lines ~242-326, 328-399, 401-569) to include analogous large-ID cases so the code paths that parse and validate IDs are exercised for overflow scenarios.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@internal/path_variable_validator.go`:
- Around line 29-36: GetIntFromRequestPath currently uses strconv.Atoi and only
checks id > 0, allowing values > int4 max which will later fail in the DB;
modify GetIntFromRequestPath to enforce a PostgreSQL int4 upper bound
(2147483647) by either using strconv.ParseInt(val, 10, 32) and rejecting parse
errors/out-of-range results or keep strconv.Atoi and add an explicit check id <=
math.MaxInt32 (2147483647) and return false if it exceeds that limit so requests
with too-large IDs are rejected at validation time.
---
Outside diff comments:
In `@internal/path_variable_validator_test.go`:
- Around line 59-102: Test suite for GetIntFromRequestPath is missing a case for
int32/int4 overflow; add a new table test entry in TestGetIntFromRequestPath
(internal/path_variable_validator_test.go) with varName "id", pathVal
"2147483648" (or math.MaxInt32+1 as string), want 0 and wantOk false to assert
overflow is rejected by validation rather than accepted by strconv.Atoi; update
the test table alongside the existing cases so the function
GetIntFromRequestPath is exercised for values > math.MaxInt32.
---
Nitpick comments:
In `@internal/product/handler_test.go`:
- Around line 145-240: Add unit tests for oversized positive IDs to
TestDeleteProduct to cover int boundary/regression from int32→int; specifically
add cases where id is "2147483648" (and similarly for platform_id in other test
suites) and ensure mockProductQuerier.deleteProductFunc handles or rejects those
values (e.g., by not being called or returning an appropriate error), then
assert the handler (productHandler.DeleteProduct) returns http.StatusBadRequest
or the expected error status; update the tests at the referenced suites (lines
~242-326, 328-399, 401-569) to include analogous large-ID cases so the code
paths that parse and validate IDs are exercised for overflow scenarios.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 5baf7179-ab98-4797-b2a5-a799507b9f30
📒 Files selected for processing (15)
internal/path_variable_validator.gointernal/path_variable_validator_test.gointernal/platform/handler_test.gointernal/platform/models.gen.gointernal/platform/platforms.sql.gen.gointernal/platform/querier.gen.gointernal/platform/request.gointernal/platform/request_test.gointernal/product/handler_test.gointernal/product/models.gen.gointernal/product/products.sql.gen.gointernal/product/querier.gen.gointernal/product/request.gointernal/product/request_test.gosqlc.yml
Description
Code Rabbit Summary
Summary by CodeRabbit
Fixes
Closes #51
Post Deployment Tasks?