quarkiverse / quarkus-renarde

Server-side Web Framework with Qute templating, magic/easier controllers, auth, reverse-routing
Apache License 2.0
74 stars 19 forks source link

@Path containing regex breaks Router #238

Closed gbourant closed 1 month ago

gbourant commented 1 month ago

For the following controller

@Path("/p/pixel")
class PixelResource extends Controller   {

    @GET
    @Path("{token}/{checksum}{extention: (\\.png)?}")
    public Response pixel(@RestPath("token") UUID token, @RestPath("checksum") Integer checksum) {
       return Response.ok().build();
    }
}

The falling call Router.getAbsoluteURI(PixelResource::pixel, UUID.fromString("453f74a6-d1f1-4cca-9322-142f9f46df09"), 477258115) returns http://localhost:8081/p/pixel/453f74a6-d1f1-4cca-9322-142f9f46df09/477258115%7Bextention:%20(%5C.png)?%7D

It adds the %7Bextention:%20(%5C.png)?%7D at the end.

FroMage commented 1 month ago

Ouch, this is definitely a bug :(

I wonder where it lies…

FroMage commented 1 month ago

Oh, perhaps because you didn't include the extention (watch out there's a typo in your code, it should be extension) in the endpoint parameter list?

gbourant commented 1 month ago

I just tried (with correct spelling) and with a new RestPath "extension"


@Path("/p/pixel")
class PixelResource extends Controller   {

    @GET
    @Path("{token}/{checksum}{extension: (\\.png)?}")
     public Response pixel(@RestPath("token") UUID token, @RestPath("checksum") Integer checksum, @RestPath("extension") String extension ) {
       return Response.ok().build();
    }
}

and Router.getAbsoluteURI(PixelResource::pixel, UUID.fromString("453f74a6-d1f1-4cca-9322-142f9f46df09"), 477258115 ,".png") returns the same http://localhost:8081/p/pixel/453f74a6-d1f1-4cca-9322-142f9f46df09/477258115%7Bextension:%20(%5C.png)?%7D

gbourant commented 1 month ago

The new param is totally ignored, for example the result of Router.getAbsoluteURI(PixelResource::pixel, UUID.fromString("453f74a6-d1f1-4cca-9322-142f9f46df09"), 477258115 ,"SOME_RANDOM_DATA") is the same as before http://localhost:8081/p/pixel/453f74a6-d1f1-4cca-9322-142f9f46df09/477258115%7Bextension:%20(%5C.png)?%7D

FroMage commented 1 month ago

OK, it's a Quarkus REST bug, I'll report it upstream.

FroMage commented 1 month ago

Reported at https://github.com/quarkusio/quarkus/issues/42249