Skip to content

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

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

fix(apiquery): reject complex elements in comma arrays#118
sylvesterkaczmarek wants to merge 1 commit 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
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