🐛 bug: fix bind struct validation only for struct targets#4082
🐛 bug: fix bind struct validation only for struct targets#4082ReneWerner87 merged 3 commits intomainfrom
Conversation
Summary of ChangesHello @ReneWerner87, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses an issue where the Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
WalkthroughAdds Changes
Sequence Diagram(s)(omitted — changes are localized to binding validation control flow and tests) Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Tip Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord. 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 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4082 +/- ##
==========================================
- Coverage 90.99% 90.98% -0.01%
==========================================
Files 119 119
Lines 11256 11266 +10
==========================================
+ Hits 10242 10250 +8
- Misses 642 643 +1
- Partials 372 373 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR adjusts Fiber’s binding validation behavior to avoid invoking StructValidator for non-struct bind targets (e.g., maps), and adds a per-bind-chain option to explicitly skip validation when desired. This aligns the implementation with the intended semantics of “struct validation” and prevents validator errors when binding into map destinations.
Changes:
- Run
StructValidatoronly when the bind destination is a struct (or pointer(s) to a struct). - Add
(*Bind).SkipValidation(bool)to enable/disable validation for a bind chain. - Add tests and documentation clarifying the updated validation behavior and the new option.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
bind.go |
Adds SkipValidation and gates struct validation to struct destinations only. |
bind_test.go |
Adds coverage ensuring map binds skip validation and SkipValidation works as intended. |
docs/guide/validation.md |
Documents that validation only runs for struct destinations. |
docs/api/bind.md |
Documents the new SkipValidation option and clarifies struct-only validation. |
There was a problem hiding this comment.
Code Review
This pull request introduces two valuable changes. First, it fixes a bug where struct validation was incorrectly attempted on non-struct types (like maps), which could lead to a panic. The fix correctly uses reflection to ensure validation is only applied to struct destinations. Second, it adds a new SkipValidation option to the binding chain, providing more control to the developer. The changes are well-implemented, accompanied by thorough tests, and the documentation has been updated accordingly. This is a solid improvement to the binding functionality.
… validation calls
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@bind_test.go`:
- Around line 2005-2024: The subtest "toggle on same bind instance" is missing
t.Parallel() which all other subtests use; inside the t.Run anonymous function
(the func(t *testing.T) passed to t.Run for the "toggle on same bind instance"
test) add a call to t.Parallel() as the first statement to enable parallel
execution—ensure it sits before acquiring the context via app.AcquireCtx and
before any shared-state operations involving c, c.Bind().SkipValidation, and
simpleQuery so the subtest runs concurrently like the others.
gaby
left a comment
There was a problem hiding this comment.
LGTM, only thing would be adding a code example in the docs using SkipValidation()
Based on feedback in discord chat