Skip to content

Conversation

@crunchydosa123
Copy link

@crunchydosa123 crunchydosa123 commented Nov 14, 2025

Pull Request Checklist

Please ensure your pull request meets the following requirements:

  • Open your pull request against the master branch.
  • All tests pass in available continuous integration systems (e.g., GitHub Actions).
  • Tests are added or modified as needed to cover code changes.
  • If the pull request introduces a new feature, the feature is documented in the docs/doc.md.

Thank you for contributing!

@crunchydosa123
Copy link
Author

crunchydosa123 commented Nov 14, 2025

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 {
Field string
Err error
}

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
Copy link

codecov bot commented Nov 15, 2025

Codecov Report

❌ Patch coverage is 75.00000% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 98.55%. Comparing base (3dc1cd6) to head (527f128).
⚠️ Report is 220 commits behind head on master.

Files with missing lines Patch % Lines
binding/form_mapping.go 75.00% 2 Missing and 2 partials ⚠️
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     
Flag Coverage Δ
?
--ldflags="-checklinkname=0" -tags sonic 98.54% <75.00%> (?)
-tags go_json 98.48% <75.00%> (?)
-tags nomsgpack 98.53% <75.00%> (?)
go-1.18 ?
go-1.19 ?
go-1.20 ?
go-1.21 ?
go-1.24 98.55% <75.00%> (?)
go-1.25 98.55% <75.00%> (?)
macos-latest 98.55% <75.00%> (-0.66%) ⬇️
ubuntu-latest 98.55% <75.00%> (-0.66%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants