-
-
Notifications
You must be signed in to change notification settings - Fork 181
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: unsupported param type url.URL #584
fix: unsupported param type url.URL #584
Conversation
Warning Rate limit exceeded@ddl-ebrown has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 4 minutes and 17 seconds before requesting another review. How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. WalkthroughThe changes enhance the Changes
Possibly related PRs
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #584 +/- ##
==========================================
+ Coverage 92.78% 92.79% +0.01%
==========================================
Files 22 22
Lines 3894 3902 +8
==========================================
+ Hits 3613 3621 +8
Misses 236 236
Partials 45 45 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Outside diff range and nitpick comments (1)
huma.go (1)
1131-1140
: Approve the new functionality for handlingurl.URL
types.The added code segment correctly parses
url.URL
types and sets the parsed value to the field. It also appropriately adds an error message to the response if parsing fails.However, as indicated by the static analysis hints, this new functionality lacks test coverage. It's crucial to add tests to ensure the robustness and reliability of the URL parsing logic.
Do you want me to assist in writing tests for this functionality or create a GitHub issue to track the task?
Tools
GitHub Check: codecov/patch
[warning] 1133-1136: huma.go#L1133-L1136
Added lines #L1133 - L1136 were not covered by tests
[warning] 1138-1140: huma.go#L1138-L1140
Added lines #L1138 - L1140 were not covered by tests
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- huma.go (2 hunks)
Additional context used
GitHub Check: codecov/patch
huma.go
[warning] 1133-1136: huma.go#L1133-L1136
Added lines #L1133 - L1136 were not covered by tests
[warning] 1138-1140: huma.go#L1138-L1140
Added lines #L1138 - L1140 were not covered by tests
Additional comments not posted (1)
huma.go (1)
1138-1140
: This code segment is part of the previous code segment reviewed, and the lack of test coverage is already addressed in the previous review comment.Tools
GitHub Check: codecov/patch
[warning] 1138-1140: huma.go#L1138-L1140
Added lines #L1138 - L1140 were not covered by tests
f8f175b
to
73191d4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Outside diff range and nitpick comments (3)
huma.go (1)
1138-1140
: Add test coverage for the newly added code.The static analysis tool
codecov/patch
indicates that the added lines 1138-1140 are not covered by tests. To ensure the correctness of theurl.URL
handling and prevent potential bugs or regressions, please add appropriate test cases that exercise this new code path.Do you want me to generate the test code or open a GitHub issue to track this task?
Tools
GitHub Check: codecov/patch
[warning] 1138-1140: huma.go#L1138-L1140
Added lines #L1138 - L1140 were not covered by testshuma_test.go (2)
Line range hint
4-4
: Reminder: Address the TODO comment.The TODO comment indicates that tests are missing for this function. Please ensure that the function is thoroughly tested to confirm that it behaves as expected.
Do you want me to generate the unit testing code or open a GitHub issue to track this task?
Line range hint
12-24
: Consider adjusting the fee structure or discount policy.The implementation of a flat $20 fee on discounted bills could negate the benefit of the discount, especially for smaller purchases or marginal loyalty tiers. This might lead to customer dissatisfaction, as the intent to reward loyalty paradoxically increases the bill.
Consider revising either the discount percentages or the flat fee application to better align with customer incentives.
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- huma.go (2 hunks)
- huma_test.go (3 hunks)
Additional context used
GitHub Check: codecov/patch
huma.go
[warning] 1138-1140: huma.go#L1138-L1140
Added lines #L1138 - L1140 were not covered by tests
Additional comments not posted (2)
huma.go (1)
1132-1140
: LGTM! The code correctly handles theurl.URL
type.The changes enhance the
Register
function to parse and validate theurl.URL
type, which is important for applications that rely on URL inputs. The code looks good and handles the parsing and error cases appropriately.Tools
GitHub Check: codecov/patch
[warning] 1138-1140: huma.go#L1138-L1140
Added lines #L1138 - L1140 were not covered by testshuma_test.go (1)
Line range hint
1-2
: LGTM!The function logic is correct, and the implementation is accurate.
73191d4
to
f78f9d5
Compare
f78f9d5
to
19b90da
Compare
}, | ||
Method: http.MethodGet, | ||
URL: "/test-params/foo/123/fba4f46b-4539-4d19-8e3f-a0e629a243b5?string=bar&int=456&before=2023-01-01T12:00:00Z&date=2023-01-01&uint=1&bool=true&strings=foo,bar&ints=2,3&ints8=4,5&ints16=4,5&ints32=4,5&ints64=4,5&uints=1,2&uints16=10,15&uints32=10,15&uints64=10,15&floats32=2.2,2.3&floats64=3.2,3.3&exploded=foo&exploded=bar", | ||
URL: "/test-params/foo/123/fba4f46b-4539-4d19-8e3f-a0e629a243b5?string=bar&int=456&before=2023-01-01T12:00:00Z&date=2023-01-01&url=http%3A%2F%2Ffoo.com%2Fbar&uint=1&bool=true&strings=foo,bar&ints=2,3&ints8=4,5&ints16=4,5&ints32=4,5&ints64=4,5&uints=1,2&uints16=10,15&uints32=10,15&uints64=10,15&floats32=2.2,2.3&floats64=3.2,3.3&exploded=foo&exploded=bar", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hope these parsing tests are sufficient @danielgtaylor.
@@ -1127,6 +1128,16 @@ func Register[I, O any](api API, op Operation, handler func(context.Context, *I) | |||
f.Set(reflect.ValueOf(t)) | |||
pv = value | |||
break | |||
// Special case: url.URL | |||
} else if f.Type() == urlType { | |||
u, err := url.Parse(value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested this in my previously failing app and all is good now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Summary by CodeRabbit
New Features
Register
function to support and validateurl.URL
types, ensuring proper handling of URL inputs.Bug Fixes