fix(apiquery): reject complex elements in comma arrays - #118
Open
sylvesterkaczmarek wants to merge 1 commit into
Open
fix(apiquery): reject complex elements in comma arrays#118sylvesterkaczmarek wants to merge 1 commit into
sylvesterkaczmarek wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Reject complex/keyed elements in comma-form query arrays instead of silently discarding their keys and flattening only their values.
Problem
internal/apiquery.encodeArraycurrently handlesArrayQueryFormatCommaby 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:
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
apiqueryerror instead of emitting a corrupted query parameter.Primitive comma arrays keep their existing behavior.
Regression coverage
Added focused tests proving that:
[]stringstill encodes asalice,bob.Validation
The branch is based directly on current upstream
main(ee92673a416c0851a5fe8907a2453db7bd450633) and contains one commit touching onlyinternal/apiquery/encoder.goplus 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.