Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix inconsistent query parameter conversion for String param #34711

Conversation

kssumin
Copy link

@kssumin kssumin commented Apr 3, 2025

Issue

When converting multiple query parameters with the same name to a single value, Spring behaves inconsistently depending on the target type:

  • For Integer parameters: /endpoint?param=1&param=2 → first value is used (1)
  • For String parameters: /endpoint?param=1&param=2 → comma-separated string is created (1,2)

This inconsistency makes behavior unpredictable and forces developers to implement workarounds.

Changes

This PR modifies WebRequestDataBinder to handle String[] to String conversion consistently with other types by only using the first value when binding web request parameters.

Tests

Added unit tests to verify consistent behavior across different parameter types.

Fixes #34613

Signed-off-by: kssumin <201566@jnu.ac.kr>
@kssumin kssumin force-pushed the fix-inconsistent-query-parameter-conversion-String-param branch from 78390d8 to ffd1e32 Compare April 3, 2025 10:00
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Apr 3, 2025
@kssumin kssumin closed this by deleting the head repository Apr 3, 2025
@bclozel bclozel added status: invalid An issue that we don't feel is valid and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Apr 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: invalid An issue that we don't feel is valid
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Inconsistent Query Parameter Conversion When Mapping Multiple Values to a Single Parameter
3 participants