-
Notifications
You must be signed in to change notification settings - Fork 8.5k
fix(binding): support custom unmarshaler for slices & arrays #4435
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
base: master
Are you sure you want to change the base?
fix(binding): support custom unmarshaler for slices & arrays #4435
Conversation
|
This PR aims to solve #4296 . Root Cause The trySetCustom function in binding/binding.go invokes: v.UnmarshalParam(val) However, since the method signature of UnmarshalParam does not include the field name, custom unmarshallers cannot attach field context to their errors. Solution This PR wraps the error returned by UnmarshalParam with a new structured error type: type FieldError struct { trySetCustom() is updated to append the field name when returning errors from BindUnmarshaler. This ensures that the standard error propagation chain includes the field name, resulting in user-friendly and debuggable error messages. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #4435 +/- ##
==========================================
- Coverage 99.21% 98.55% -0.66%
==========================================
Files 42 44 +2
Lines 3182 2984 -198
==========================================
- Hits 3157 2941 -216
- Misses 17 28 +11
- Partials 8 15 +7
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:
|
Pull Request Checklist
Please ensure your pull request meets the following requirements:
masterbranch.docs/doc.md.Thank you for contributing!