🐛 bug: custom binders bypass StructValidator in Body() and Custom()#4124
Merged
Conversation
Co-authored-by: ReneWerner87 <7063188+ReneWerner87@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix validation issue with custom binders in Body()
🐛 bug: custom binders bypass StructValidator in Body() and Custom()
Mar 2, 2026
ReneWerner87
approved these changes
Mar 4, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4124 +/- ##
==========================================
- Coverage 91.11% 91.08% -0.04%
==========================================
Files 119 119
Lines 11377 11381 +4
==========================================
Hits 10366 10366
- Misses 641 645 +4
Partials 370 370
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:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Custom binders registered via
RegisterCustomBindersilently skippedStructValidatorwhen invoked throughBody()orCustom(), while all built-in binders (JSON, XML, Form, CBOR, MsgPack, etc.) correctly run validation after parsing.Changes introduced
Body(): after a custom binder successfully parses the request,validateStruct(out)is now called before returning — consistent with all built-in binder paths.Custom(): same fix applied;validateStruct(dest)is called after successful parse.Test_Bind_CustomBinder_Validationwith subtests covering pass/fail validation for bothBody()andCustom().Body()andCustom()now invokeStructValidator, matching built-in binder behavior.SkipValidation(true)to opt out.Type of change
Checklist
/docs/directory for Fiber's documentation.Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
exampleretry.com/tmp/go-build982216137/b307/client.test /tmp/go-build982216137/b307/client.test -test.paniconexit0 -test.v=test2json -test.timeout=10m0s -test.count=1 -test.shuffle=on k/fiber/fiber/middleware/limitertext/tabwriter ux-amd64/pkg/tool/linux_amd64/compile -p github.com/santh-unsafeptr=false -lang=go1.21 ux-amd64/pkg/too/tmp/go-build982216137/b113/vet.cfg -o rg/toolchain@v0.0.1-go1.25.0.lin. -trimpath ux-amd64/pkg/tool/linux_amd64/vet pkg/mod/golang.o/usr/bin/python3 github.com/gofib-u l/linux_amd64/cobin/WALinuxAgent-2.15.1.3-py3.12.egg ux-amd64/pkg/too-collect-logs(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.