-
Notifications
You must be signed in to change notification settings - Fork 16
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 on single letter query param zhttp #101
Conversation
WalkthroughThe pull request updates the safe extraction of data in the Changes
Sequence Diagram(s)sequenceDiagram
participant T as TestRequestParams
participant D as urlDataProvider.Get
participant U as UserStruct Mapper
T->>D: Call Get(key: "q")
D->>D: Check if len(key) > 2 and key ends with "[]"
D-->>T: Return parameter value ("test")
T->>U: Map returned data to User struct (field Q)
U-->>T: User with Q = "test"
T->>T: Assert Q equals "test"
Poem
✨ Finishing Touches
🪧 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 (
|
This addresses #96 |
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
🧹 Nitpick comments (1)
zhttp/zhttp_test.go (1)
75-75
: Consider using consistent struct tags.The struct uses
param
tags for other fields butzog
for the new fieldQ
. Consider using consistent tags across all fields.- Q string `zog:"q"` + Q string `param:"q"`
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
zhttp/zhttp.go
(1 hunks)zhttp/zhttp_test.go
(4 hunks)
🔇 Additional comments (2)
zhttp/zhttp.go (1)
56-56
: LGTM! Good fix for the panic issue.The added length check prevents index out of range panic for short keys while maintaining the original array detection logic.
zhttp/zhttp_test.go (1)
59-59
: LGTM! Good test coverage for the fix.The test properly validates the handling of single letter query parameters through:
- Adding a single letter query param 'q'
- Validating its parsing and schema validation
- Ensuring correct value propagation
Also applies to: 75-75, 87-87, 101-101
Summary by CodeRabbit
Bug Fixes
New Features