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 parameter validation issue in classic rest-client #33918

Merged
merged 1 commit into from
Jun 22, 2023

Conversation

kahowell
Copy link
Contributor

@kahowell kahowell commented Jun 8, 2023

URL parsing inside of QuarkusRestClientBuilder.verifyInterface used ResteasyUriBuilderImpl.uri, which works for most cases, but parsed in subtly wrong ways when the constructed path started with //. For example, a path of //{id} parses {id} as the hostname. Such a path was possible to trigger by a couple of scenarios:

  1. Interface has @Path(""), and a method-level @Path value starting with /.
  2. Interface has @Path("/"), and a method-level @Path value not starting with /.

Furthermore, if the first path component contained a path param, then it would not be counted, leading to incorrect validation results.

Fixes: #33915

Copy link
Contributor

@Sgitario Sgitario left a comment

Choose a reason for hiding this comment

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

Can you add the same test in the REST Client Reactive extension?
I could not confirm that after these changes, the reproducer in the linked issue behaved the same in the classic and the reactive REST clients.

@kahowell
Copy link
Contributor Author

@Sgitario I added a test for rest-client-reactive as requested. Please take another look when you have a chance.

@quarkus-bot

This comment has been minimized.

@Sgitario
Copy link
Contributor

@Sgitario I added a test for rest-client-reactive as requested. Please take another look when you have a chance.

Many thanks! You need to build the modules you changed using Maven, so the files get formatted, (mvn clean install will do it). Also, squash all the commits, so we can proceed with the merge after CI is green.

URL parsing inside of `QuarkusRestClientBuilder.verifyInterface` used
`ResteasyUriBuilderImpl.uri`, which works for most cases, but parsed in
subtly wrong ways when the constructed path started with `//`. For
example, a path of `//{id}` parses `{id}` as the hostname. Such a path
was possible to trigger by a couple of scenarios:

1. Interface has `@Path("")`, and a method-level `@Path` value starting
   with `/`.
2. Interface has `@Path("/")`, and a method-level `@Path` value not
   starting with `/`.

Furthermore, if the first path component contained a path param, then it
would not be counted, leading to incorrect validation results.

Added an empty path test to rest-client-reactive.
@kahowell kahowell force-pushed the resteasy-classic-pathparam-bugfix branch from d0f6637 to 8c0e055 Compare June 21, 2023 17:13
@kahowell
Copy link
Contributor Author

d0f6637 to 8c0e055: use ./mvnw process-sources to fix formatting, rebase against main

@quarkus-bot
Copy link

quarkus-bot bot commented Jun 22, 2023

✔️ The latest workflow run for the pull request has completed successfully.

It should be safe to merge provided you have a look at the other checks in the summary.

@Sgitario Sgitario merged commit 4e30b33 into quarkusio:main Jun 22, 2023
@quarkus-bot quarkus-bot bot added this to the 3.3 - main milestone Jun 22, 2023
@Sgitario
Copy link
Contributor

Great, many thanks!

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

Successfully merging this pull request may close these issues.

RestClientDefinitionException: Parameters and variables don't match, with @Path("") on interface
2 participants