Skip to content

fix(apiquery): reject complex elements in comma arrays - #118

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

fix(apiquery): reject complex elements in comma arrays#118
sylvesterkaczmarek wants to merge 2 commits into
openai:mainfrom
sylvesterkaczmarek:fix/apiquery-comma-complex-elements

Conversation

@sylvesterkaczmarek

Copy link
Copy Markdown

Summary

Reject complex/keyed elements in comma-form query arrays instead of silently discarding their keys and flattening only their values.

Problem

internal/apiquery.encodeArray currently handles ArrayQueryFormatComma by recursively encoding each array element and appending every returned pair's value to the comma-delimited list. For map/object elements, that means the nested query keys are lost.

For example, a value shaped like:

map[string]any{
    "filter": []map[string]string{{"name": "alice"}},
}

can be reduced to a query equivalent to filter=alice, which no longer represents the original object structure and gives the caller no indication that serialization changed its meaning.

Fix

Require each comma-form element to encode to exactly one unkeyed scalar pair. If recursive encoding produces keyed or multiple pairs, return a clear apiquery error instead of emitting a corrupted query parameter.

Primitive comma arrays keep their existing behavior.

Regression coverage

Added focused tests proving that:

  • an array containing map/object elements returns an error and no query values;
  • an ordinary []string still encodes as alice,bob.

Validation

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

Risk

Low. The newly rejected inputs are shapes whose key structure cannot be represented by the comma-array encoding. Existing primitive comma arrays and the repeat/indices/brackets array formats are unchanged.

@sylvesterkaczmarek
sylvesterkaczmarek requested a review from a team as a code owner August 20, 2026 20:07
@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:56:29.300604Z f50b438 New commits
🔒 Security Review Completed 2026-09-06T07:57:10.746937Z f50b438 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: 0dbb1d8b19

ℹ️ 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".

}
for _, pair := range innerPairs {
elements = append(elements, pair.value)
if len(innerPairs) != 1 || innerPairs[0].key != "" {

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 Reject nested arrays before recursive comma encoding

When an element is itself an array or slice, the recursive call returns exactly one unkeyed pair, so this condition accepts it; for example, [][]string{{"a", "b"}} is still flattened to a,b, losing the nested-array boundary instead of producing the promised complex-element error. Check the element's dereferenced kind before recursion, and add nested-array regression coverage alongside the map case.

AGENTS.md reference: AGENTS.md:L65-L68

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 f50b438. Comma-array encoding now rejects dereferenced array, slice, map, and struct elements before recursive encoding. Added nested-array regression coverage; focused apiquery tests pass.

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 f50b438. Comma-form encoding now rejects nested slices/arrays before recursive encoding, so their boundaries cannot be flattened accidentally. Added regression coverage for nested arrays while retaining the existing primitive-array behavior. go test ./internal/apiquery passes.

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 0dbb1d8b19

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