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 params #34713

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

@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 force-pushed the fix-inconsistent-query-parameter-conversion-String-param branch from aa5d826 to 90f17a9 Compare April 4, 2025 02:20
@bclozel
Copy link
Member

bclozel commented Apr 7, 2025

Original issue has been declined. #34613 (comment)

Thanks for your contribution.

@bclozel bclozel closed this Apr 7, 2025
@bclozel bclozel added status: declined A suggestion or change that we don't feel we should currently apply and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Apr 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: declined A suggestion or change that we don't feel we should currently apply
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