Skip to content

fix(apiform): support primitive pointers in comma arrays - #119

Open
sylvesterkaczmarek wants to merge 1 commit into
openai:mainfrom
sylvesterkaczmarek:fix/apiform-comma-pointer-elements
Open

fix(apiform): support primitive pointers in comma arrays#119
sylvesterkaczmarek wants to merge 1 commit into
openai:mainfrom
sylvesterkaczmarek:fix/apiform-comma-pointer-elements

Conversation

@sylvesterkaczmarek

Copy link
Copy Markdown

Summary

Dereference non-nil pointer/interface elements when encoding multipart arrays with FormatComma, while preserving the existing empty-string representation for nil elements.

Problem

internal/apiform.encodeArray already special-cases nil pointer/interface elements in comma-form arrays, but non-nil pointers are never dereferenced before the primitive-type switch.

As a result, a valid primitive array such as:

[]*string{&first, nil, &second}

fails with:

comma format not supported for complex array elements

even though the pointed-to values are ordinary strings and the same encoder supports primitive values directly.

Fix

Unwrap pointer and interface layers before primitive comma serialization. If a nil value is encountered at any layer, keep the existing behavior of adding an empty comma element.

Complex non-primitive elements continue to return the same error as before.

Regression coverage

Added a focused multipart regression for []*string{&first, nil, &second} and verify it serializes as:

alpha,,beta

Validation

The branch is based directly on current upstream main (ee92673a416c0851a5fe8907a2453db7bd450633) and contains one commit touching only internal/apiform/encoder.go plus focused regression coverage. Full Go test execution is left to repository CI.

Risk

Low. The change only affects pointer/interface elements inside FormatComma arrays. Direct primitives, nil elements, complex-element rejection, and all other multipart array formats retain their existing behavior.

@sylvesterkaczmarek
sylvesterkaczmarek requested a review from a team as a code owner August 20, 2026 20:09
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