Skip to content

Convert elements of collection- and array-valued query method parameters - #3514

Open
seonwooj0810 wants to merge 3 commits into
spring-projects:mainfrom
seonwooj0810:fix/gh-3502-collection-enum-param-conversion
Open

seonwooj0810 wants to merge 3 commits into
spring-projects:mainfrom
seonwooj0810:fix/gh-3502-collection-enum-param-conversion

Conversation

@seonwooj0810

@seonwooj0810 seonwooj0810 commented Jul 24, 2026 •

Copy link
Copy Markdown

Fixes #3502

prepareParameters skipped conversion when the value was already an instance of the parameter type, so a List<String> bound to a Collection<Color> parameter never had its elements converted. Array and Iterable parameters are now always passed through conversion.

…ers.

Query method parameters exposed through Spring Data REST were passed to the
backing repository without element conversion when the raw value already was
an instance of the declared target type (e.g. a `List`). As a result, a
repeated request parameter such as `?colors=RED&colors=GREEN` reached an
`in`-style query as a `List<String>` instead of a `List<Color>`, causing the
persistence provider to fail.

`ReflectionRepositoryInvoker` now also invokes conversion for array- and
`Iterable`-typed parameters even when the value already matches the target
type, so the raw elements get converted to the declared element type.

Signed-off-by: seonwoo_jung <79202163+seonwooj0810@users.noreply.github.com>
@seonwooj0810

Copy link
Copy Markdown
Author

Following up on this one — let me know if the approach needs rework or if anything's blocking a look.

Object value = unwrapSingleElement(rawParameters.get(parameterName));

result[i] = targetType.isInstance(value) ? value : convert(value, param);
// Collection- and array-valued parameters must be converted even if the value already is an instance of

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please refrain from adding arbitrary comments into code introducing ticket references. These cause rather distraction and noise and we are not going to merge these changes in their current form.

Signed-off-by: seonwooj0810 <seonwooj0810@gmail.com>
@seonwooj0810

Copy link
Copy Markdown
Author

Thanks for the review, @mp911de. I removed the ticket reference (and the surrounding comment) from the code in 33df041; the logic is unchanged.

@mp911de

mp911de commented Oct 5, 2026

Copy link
Copy Markdown
Member

Well, now it seems I am talking to AI.

The problem with these kind of pull requests is that (while I appreciate usage of AI to bridge communications), that they are bloated. Do you seriously ask us to read walls of text? This is to some degree an concern regarding respect towards maintainers. Besides all else,

Change
For array- and Iterable-typed parameters, conversion is now performed even when the value already matches the target type, so the elements are converted to the declared element type. Scalar parameters keep the previous fast-path (no redundant conversion).

Tests
Added ReflectionRepositoryInvokerUnitTests#convertsElementsOfCollectionValuedQueryParameter, which binds a List to a Collection query parameter and asserts the repository receives converted enum values. It fails before the change (repository receives the raw Strings) and passes after.

Verification done: (1) no in-flight PR — searched open PRs for 3502 and ReflectionRepositoryInvoker (only unrelated #3439); (2) no self-claim comments; assignee odrotbohm is routine triage tracking (89 open issues assigned); (3) code-focused, touches only .java; (4) confirmed the pattern still present on current main; (6) issue is past triage (type: bug), so no triage gate. Ran ./mvnw -o test -Dtest=ReflectionRepositoryInvokerUnitTests — 20/20 pass with the fix; the new test fails without it.

Is just noise and requires effort from our time where it contains actually something useful or whether it restates what the diff already shows. Such pull requests are annoying an if this wouldn't had a bug characteristic, its negative value wants me to immediately it.

Going forward, please make sure you thoroughly reviewed both, code changes and the description. We have 100's of similar looking pull requests, all full of text resulting on a DDoS on our time and willingness to accept contributions.

Signed-off-by: seonwoo_jung <79202163+seonwooj0810@users.noreply.github.com>
@seonwooj0810

Copy link
Copy Markdown
Author

Fair point. I cut the description down to the actual change and removed the leftover ticket comment from the test in d6d788c. I'll keep future PRs short.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: waiting-for-triage An issue we've not yet triaged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Query exposed through Spring-Data-Rest will throw an exception if configured a filter on a List of enums

4 participants