-
-
Notifications
You must be signed in to change notification settings - Fork 232
fix: panic - allow for parameters to be subtype of string #592
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: panic - allow for parameters to be subtype of string #592
Conversation
WalkthroughThe changes in this pull request enhance the Changes
Possibly related PRs
Suggested reviewers
Poem
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 (
|
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: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (2)
- huma.go (1 hunks)
- huma_test.go (5 hunks)
🔇 Additional comments (5)
huma_test.go (5)
72-73: Definition of new typeCustomStringParamThe new type
CustomStringParamdefined as an alias forstringis appropriately declared. This allows for custom handling or validation of string parameters if needed.
350-369: Addition ofCustomStringParamto query parametersThe query parameters
QueryCustomStringandQueryCustomStringsare correctly added to the input struct using the new typeCustomStringParamand its slice[]CustomStringParam. The struct tags are appropriately specified for proper query binding.
388-388: Assertion ofQueryCustomStringvalueThe assertion correctly verifies that
input.QueryCustomStringmatches the expected value ofCustomStringParam("bar").
397-397: Assertion ofQueryCustomStringsvaluesThe assertion accurately checks that
input.QueryCustomStringscontains the expected slice[]CustomStringParam{"foo", "bar"}.
425-425: Update test URL to include new query parametersThe test URL is properly updated to include the
customStringandcustomStringsquery parameters with appropriate values, ensuring that these parameters are correctly parsed and tested.
|
Bot saved me wrong merge removed that one line i next commit |
a7244da to
3252a7a
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: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (2)
- huma.go (1 hunks)
- huma_test.go (5 hunks)
🔇 Additional comments (5)
huma_test.go (5)
72-73: Definition ofCustomStringParamis appropriateThe new type
CustomStringParamdefined asstringis suitable for testing custom parameter types.
350-369: New custom query parameters usingCustomStringParamare correctly addedThe
QueryCustomStringandQueryCustomStringsparameters are appropriately defined using theCustomStringParamtype and added to the test input struct, effectively testing custom parameter handling.
388-388: Assertion ofCustomStringParamvalue is correctThe assertion correctly compares
input.QueryCustomStringwithCustomStringParam("bar"), ensuring proper handling of custom string parameters.
397-397: Assertion of[]CustomStringParamvalues is correctThe assertion correctly compares
input.QueryCustomStringswith[]CustomStringParam{"foo", "bar"}, ensuring proper handling of slices of custom string parameters.
425-425: Test URL includes new custom query parametersThe test URL correctly includes
customStringandcustomStringsquery parameters, facilitating proper testing of custom string parameter handling.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #592 +/- ##
==========================================
+ Coverage 92.80% 92.81% +0.01%
==========================================
Files 22 22
Lines 3903 3911 +8
==========================================
+ Hits 3622 3630 +8
Misses 236 236
Partials 45 45 ☔ View full report in Codecov by Sentry. |
Huma panics when query param is slice of string subtypes
for example

results in panic
This pullrequest is a fix to that. First time i used golang reflection so feel free to clean it up a bit.
Summary by CodeRabbit
New Features
Bug Fixes
Tests