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

Request param handling in HttpRequestValues overrides existing URI variables with same name #34499

Closed
matejkobza opened this issue Feb 26, 2025 · 2 comments
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: regression A bug that is also a regression
Milestone

Comments

@matejkobza
Copy link

matejkobza commented Feb 26, 2025

Following changes here (pulled with update of spring boot 3.4.2):
d927d64

I have found out that in case of connector definition like

@HttpExchange(
            method = "GET",
            value = "/transfers/{transfer-id}",
            accept = {"application/json"}
    )
    ResponseEntity<Transfer> getTransfer(@PathVariable("transfer-id") String transferId, @RequestParam(value = "transfer-id") String transferIdReqParamValue, @RequestParam(value = "hint",required = false) String hint, @RequestParam(value = "include",required = false) List<String> include, @RequestParam(value = "trim",required = false) List<String> trim);

causes problem in incorrect replacement of transfer-id path variable.

I am trying to assign "{transfer-id}" as path variable value of transfer-id and curly brackets are removed during HttpRequestValues.appendQueryParams execution and it causes to be modified in resulting GET request from:

/transfers/{transfer-id}?transfer-id=1234

to

/transfers/transfer-id?transfer-id=1234 

which is incorrect.

Image

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Feb 26, 2025
@matejkobza
Copy link
Author

matejkobza commented Feb 26, 2025

It seems that the problem is even deeper, it substitutes value of pathVariable which has the same name as queryParameter with name of queryParameter and actual value of path variable is lost.

@matejkobza matejkobza changed the title Path variable with same query parameter causes replacement of path variable value in request Path variable with same query parameter name causes replacement of path variable value in request Feb 26, 2025
@rstoyanchev rstoyanchev self-assigned this Feb 27, 2025
@rstoyanchev rstoyanchev added in: web Issues in web modules (web, webmvc, webflux, websocket) and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Feb 27, 2025
@rstoyanchev rstoyanchev added this to the 6.2.4 milestone Feb 27, 2025
@rstoyanchev rstoyanchev added the type: regression A bug that is also a regression label Feb 27, 2025
@rstoyanchev
Copy link
Contributor

Thanks for report and analysis. Indeed, since the query param handling now uses URI vars that are based on the actual query param name, it ends up overriding any existing URI variables (in this case for the path variable) if they have the same name.

@rstoyanchev rstoyanchev changed the title Path variable with same query parameter name causes replacement of path variable value in request Request param handling in HttpRequestValues overrides existing URI variables with same name Feb 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: regression A bug that is also a regression
Projects
None yet
Development

No branches or pull requests

3 participants