Skip to content

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

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

fix(apiform): support primitive pointers in comma arrays#119
sylvesterkaczmarek wants to merge 2 commits 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
@markstuart-oai

Copy link
Copy Markdown
Contributor

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 6, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-06T07:55:38.122598Z 877e5ff New commits
🔒 Security Review Completed 2026-09-06T07:59:25.048481Z 877e5ff New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cfc696f92e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

item = reflect.Value{}
break
}
item = item.Elem()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve float32 precision after pointer unwrapping

When a comma-form array contains a non-nil *float32, this new unwrapping path reaches the existing combined float case, which calls strconv.FormatFloat with a 64-bit size. Consequently, a value such as float32(1.2) is sent as 1.2000000476837158 rather than 1.2, unlike the scalar encoder's dedicated Float32 handling. Distinguish reflect.Float32 from reflect.Float64 when serializing these newly supported pointer elements.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 877e5ff. Pointer-unwrapped float32 values now use 32-bit formatting, with a regression for float32(1.2) producing 1.2. Focused apiform tests pass.

@chatgpt-codex-connector

Copy link
Copy Markdown

Security review completed. No security issues were found in this pull request.

Reviewed commit: cfc696f92e

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

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