Repository navigation
Fixes stray separators when expanding iterables with empty members - #3688
Merged
velo merged 1 commit intoNov 16, 2026
Merged
Conversation
`SimpleExpression.expandIterable` tracked separators by inspecting the
buffer built so far, which miscounted once more than one empty member
was involved. Expanding a list that was empty or had consecutive empty
members leaked extra separators.
Examples (simple expansion of `{ids}`):
* `[""]` expanded to `,` instead of an empty string
* `["", "", "c"]` expanded to `,,,c` instead of `,,c`
Path-style (`{;ids}`) expansion had the matching defect, dropping the
variable name on empty members (`;ids=a;` instead of `;ids=a;ids=`).
Replaced the heuristic with a first-member flag so members are joined by
exactly one separator and an empty member expands to an empty string,
matching RFC 6570. Query parameters already strip blank values, so the
observable change is limited to path and path-style expansion.
Added regression tests in UriTemplateTest for both forms.
velo
approved these changes
Nov 16, 2026
velo
left a comment
Member
There was a problem hiding this comment.
LGTM - fixing stray separators when expanding iterables with empty members. Correct and well-tested.
velo
enabled auto-merge (squash)
November 16, 2026 10:57
Contributor
Author
|
Thanks for merging 🙏 |
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.
Problem
Expressions.SimpleExpression.expandIterabledecided where to place separators by inspecting the buffer built so far (result.toString().equalsIgnoreCase(this.separator)). That check only holds when at most one empty member has been seen, so lists that were empty or contained consecutive empty members leaked extra separators.Simple expansion of
/path/{ids}:[""]/path/,/path/["", "", "c"]/path/,,,c/path/,,cPath-style expansion of
{;ids}had the matching defect and also dropped the variable name on an empty member:[""];;;ids=["a", ""];ids=a;;ids=a;ids=Fix
Replaced the buffer-inspection heuristic with a simple first-member flag. Members are now joined by exactly one separator, and an empty member expands to an empty string while still counting as a member, which matches RFC 6570 simple and path-style expansion.
Query parameters strip blank values before expansion (
QueryTemplatefilters withUtil::isNotBlank), so the observable change is limited to path and path-style (;) expansion. Existing behavior for non-empty members and for a single leading empty member is unchanged.Tests
Added two regression tests in
UriTemplateTestcovering simple and path-style expansion with empty members. Both fail onmasterand pass with this change. Verified locally withmvn -pl core test(template and request suites, JDK 25 toolchain).AI-assisted; directed, reviewed and tested by the author (amalsaidov).