Skip to content

fix: support ParamWrapper types in multipart form value fields - #1087

Open
stareezy-1 wants to merge 1 commit into
danielgtaylor:mainfrom
stareezy-1:fix/958-paramwrapper-multipart
Open

fix: support ParamWrapper types in multipart form value fields#1087
stareezy-1 wants to merge 1 commit into
danielgtaylor:mainfrom
stareezy-1:fix/958-paramwrapper-multipart

Conversation

@stareezy-1

@stareezy-1 stareezy-1 commented Aug 5, 2026

Copy link
Copy Markdown

Summary

Fixes #958

Problem

ParamWrapper-based types work for query/header/path parameters but fail inside MultipartFormFiles[T] form value fields. A wrapper-backed value type (e.g. a big-int whose parsing is delegated to a text-unmarshalling wrapper via Receiver()) fails at request time:

422 Unprocessable Entity
"message": "unsupported param type: utils.BigInt"
"location": "form.step_id"

Root cause: the non-multipart parameter path unwraps ParamWrapper.Receiver() before calling parseInto, but the multipart form-value parser calls parseInto directly on the struct field. The wrapper value therefore never reaches the encoding.TextUnmarshaler check 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:

receiver := f
if f.Addr().Type().Implements(paramWrapperType) {
    receiver = f.Addr().Interface().(ParamWrapper).Receiver()
}
pv, err := parseInto(ctx, receiver, value[0], value, *p)

Tests

TestMultipartFormFileWrapperParam added to huma_test.go, reproducing the issue shape: a value type implementing only Schema/String, with parsing delegated via Receiver() to a wrapper implementing UnmarshalText.

Behavior Verifies
Without the fix request fails with the reported unsupported param type 422
With the fix form value parses; handler returns 200 with the expected payload

All existing tests continue to pass (go test -race ./...).

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.
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.

ParamWrapper does not support MultipartFormFiles[T]

1 participant