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

Matching a base path of another controller, results in 405 Method Not Allowed #26496

Open
ivansenic opened this issue Jul 1, 2022 · 8 comments
Labels
area/rest kind/bug Something isn't working

Comments

@ivansenic
Copy link
Contributor

Describe the bug

It took me some time to understand the bug I am hitting, but now I am pretty certain it's a bug and it's reproducible. Let's imagine you have two controllers:

@Path("/base")
class Base {

   @GET
   @Path("{id}") 
   public Uni<RestResponse<?>> base() {..}
}

@Path("/base/{id}")
class Extension {

   @GET
   @Path("extension") 
   public Uni<RestResponse<?>> extension() {..}
}

Calling GET /base/123 will result in HTTP 405 Method Not Allowed. Note that:

  • endpoints are correctly visible in the Dev UI List of endpoints
  • endpoints are correctly included in Open API and Swagger UI

However, seems that the base-path of the second controller is hiding the first controller in case when things are getting resolved in the org.jboss.resteasy.reactive.server.handlers.ClassRoutingHandler.

Expected behavior

Target method executed correctly.

Actual behavior

405 Method Not Allowed

How to Reproduce?

No response

Output of uname -a or ver

No response

Output of java -version

No response

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.10.0.Final

Build tool (ie. output of mvnw --version or gradlew --version)

Maven home: /home/ise/.m2/wrapper/dists/apache-maven-3.8.4-bin/52ccbt68d252mdldqsfsn03jlf/apache-maven-3.8.4 Java version: 17.0.3, vendor: Private Build, runtime: /usr/lib/jvm/java-17-openjdk-amd64 Default locale: en_US, platform encoding: UTF-8 OS name: "linux", version: "5.13.0-51-generic", arch: "amd64", family: "unix"

Additional information

Workaround is to match base paths in both controllers:

@Path("/base")
class Base {

   @GET
   @Path("{id}") 
   public Uni<RestResponse<?>> base() {..}
}

@Path("/base")
class Extension {

   @GET
   @Path("{id}/extension") 
   public Uni<RestResponse<?>> extension() {..}
}
@ivansenic ivansenic added the kind/bug Something isn't working label Jul 1, 2022
@geoand
Copy link
Contributor

geoand commented Jul 1, 2022

I am not sure this is allowed as per the JAX-RS spec.
@sberyozkin, @FroMage do you know?

@quarkus-bot
Copy link

quarkus-bot bot commented Jul 1, 2022

/cc @FroMage, @stuartwdouglas

@ivansenic
Copy link
Contributor Author

I am not sure this is allowed as per the JAX-RS spec. @sberyozkin, @FroMage do you know?

Really? Hmm, I know this is possible in Spring, although the have different annotations..

OK if this is the case, then it's my bad..

@geoand
Copy link
Contributor

geoand commented Jul 1, 2022

Really? Hmm, I know this is possible in Spring, although the have different annotations..

Spring doesn't implement JAX-RS :)

OK if this is the case, then it's my bad..

I'm not sure either, lets see if others know for sure

@FroMage
Copy link
Member

FroMage commented Jul 20, 2022

Well, frankly, the JAX-RS spec routing algo I never understood: https://jakarta.ee/specifications/restful-ws/3.1/jakarta-restful-ws-spec-3.1.html#request_matching

But the use-case looks legit to me, both classes should be analogous IMO, since in both cases the endpoints have the same URIs. So IMO we should support this.

@geoand
Copy link
Contributor

geoand commented Jul 26, 2022

I agree it would be useful

@pehunka
Copy link

pehunka commented Sep 26, 2023

Hi team, same issue here .. is there anything I can do to workaround it?

@geoand
Copy link
Contributor

geoand commented Sep 26, 2023

For the time being, only to not have overlapping paths.

But we should definitely address this one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/rest kind/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants