fix: support ParamWrapper types in multipart form value fields - #1087
Open
stareezy-1 wants to merge 1 commit into
Open
fix: support ParamWrapper types in multipart form value fields#1087stareezy-1 wants to merge 1 commit into
stareezy-1 wants to merge 1 commit into
Conversation
The multipart form-value path parsed each field with parseInto directly on the struct field, skipping the ParamWrapper.Receiver() unwrap that the query/header/path path applies. Wrapper types (e.g. a big-int backed by a text-unmarshalling wrapper) therefore failed at request time with 'unsupported param type'. Unwrap the receiver before parsing, matching the non-multipart parameter path.
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.
Summary
Fixes #958
Problem
ParamWrapper-based types work for query/header/path parameters but fail insideMultipartFormFiles[T]form value fields. A wrapper-backed value type (e.g. a big-int whose parsing is delegated to a text-unmarshalling wrapper viaReceiver()) fails at request time:Root cause: the non-multipart parameter path unwraps
ParamWrapper.Receiver()before callingparseInto, but the multipart form-value parser callsparseIntodirectly on the struct field. The wrapper value therefore never reaches theencoding.TextUnmarshalercheck that the non-multipart path relies on.Fix
Apply the same receiver unwrap in the multipart form-value path before parsing, mirroring the query/header/path parameter path:
Tests
TestMultipartFormFileWrapperParamadded tohuma_test.go, reproducing the issue shape: a value type implementing onlySchema/String, with parsing delegated viaReceiver()to a wrapper implementingUnmarshalText.unsupported param type422200with the expected payloadAll existing tests continue to pass (
go test -race ./...).