Skip to content

fix: bind uuid.UUID fields in deepObject parameters - #171

Open
youdie006 wants to merge 1 commit into
oapi-codegen:mainfrom
youdie006:deepobject-array-text-unmarshaler
Open

youdie006 wants to merge 1 commit into
oapi-codegen:mainfrom
youdie006:deepobject-array-text-unmarshaler

Conversation

@youdie006

Copy link
Copy Markdown

#45 (for #44) added a TextUnmarshaler check to the struct branch of assignPathValues so that types like uuid.UUID bind. But uuid.UUID is [16]byte, an array kind, so it never reaches that branch, and a deepObject parameter with a format: uuid field still fails:

?filter[entity]=6ba7b810-9dad-11d1-80b4-00c04fd430c8
error assigning value to destination: error assigning field [entity]: unhandled type: uuid.UUID

This adds a reflect.Array case that uses UnmarshalText when the type implements it, as BindStringToObject already does (bindstring.go). Other arrays still return unhandled type.

TestDeepObject_UUIDFields covers uuid.UUID and *uuid.UUID fields, an invalid UUID, and a plain [2]string. The first two rows fail on main. go test ./..., go vet and golangci-lint (2.13.2 locally, CI uses 2.15.0) pass.

Written with AI assistance (Claude); I have reviewed the change.

uuid.UUID is a [16]byte array, so it never reached the TextUnmarshaler check that oapi-codegen#45 added to the struct branch and still failed with "unhandled type: uuid.UUID". Handle array kinds that implement encoding.TextUnmarshaler, as BindStringToObject already does.
@youdie006
youdie006 requested a review from a team as a code owner October 27, 2026 16:20
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.

1 participant