quarkusio / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
13.63k stars 2.64k forks source link

Quarkus returns 404 on OPTIONS request for the static resources #32696

Closed zenonwch closed 1 year ago

zenonwch commented 1 year ago

Describe the bug

I have static resources under the /src/resources/META-INF/resources folder (ex.: /src/resources/META-INF/resources/img/document.png.

When I make a GET call for the resource - Qurkus responds with 200 OK and returns the resource But when I make an OPTIONS call for the same resource - Quarkus responds with 404 Not found

Expected behavior

I expected 200 OK on the OPTIONS request for the static resources.

Actual behavior

Quarkus responds with 404 Not found on the OPTIONS request for the static resources

How to Reproduce?

  1. Add a static resource to the sample Quarkus project under the /src/resources/META-INF/resources folder
  2. Try to call this resource with GET and OPTIONS requests.

Sample of RestAssured @QuarkusTest

Output of uname -a or ver

linux, macOS, Windows

Output of java -version

openjdk 17.0.2 2022-01-18

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.16.5.Final

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

Apache Maven 3.8.1 (05c21c65bdfed0f71a2f2ada8b84da59348c4c5d)

Additional information

No response

geoand commented 1 year ago

Which extensions are you using?

zenonwch commented 1 year ago

@geoand, I don't clearly understand what you mean by extensions. But we use the following Quarkus dependencies: io.quarkus:quarkus-core:2.16.5.Final io.quarkus:quarkus-resteasy:2.16.5.Final io.quarkus:quarkus-resteasy-jackson:2.16.5.Final io.quarkus:quarkus-jackson:2.16.5.Final io.quarkus:quarkus-smallrye-openapi:2.16.5.Final io.quarkus:quarkus-smallrye-opentracing:2.16.5.Final io.quarkus:quarkus-smallrye-metrics:2.16.5.Final io.quarkus:quarkus-config-yaml:2.16.5.Final io.quarkus:quarkus-kotlin:2.16.5.Final io.quarkus:quarkus-rest-client:2.16.5.Final io.quarkus:quarkus-oidc:2.16.5.Final io.quarkus:quarkus-reactive-routes:2.16.5.Final io.quarkus:quarkus-logging-gelf:2.16.5.Final io.quarkus:quarkus-hibernate-validator:2.16.5.Final io.quarkus:quarkus-narayana-jta:2.16.5.Final io.quarkus:quarkus-smallrye-jwt:2.16.5.Final io.quarkus:quarkus-smallrye-health:2.16.5.Final io.quarkiverse.logging.logback:quarkus-logging-logback:0.13.0

and for tests io.quarkus:quarkus-junit5-mockito:2.16.5.Final io.quarkus:quarkus-test-security-jwt:2.16.5.Final io.quarkus:quarkus-jdbc-h2:2.16.5.Final

geoand commented 1 year ago

Close enough :)

Could you attach the sample application you are using please? It will make things a lot easier for us.

Thanks

zenonwch commented 1 year ago

@geoand, I created as simple as possible project - https://github.com/zenonwch/test-static-resource-options

geoand commented 1 year ago

Thanks.

I am getting a 404 with that link however

gsmet commented 1 year ago

I think I recall we enabled GET and HEAD for static resources. We might have to also enable OPTIONS.

(but that's a very vague recollection so I might be mistaken)

geoand commented 1 year ago

Very likely, however I don't remember at all. I'll have a look later on.

gsmet commented 1 year ago

That would be it I think: https://github.com/quarkusio/quarkus/blob/main/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/StaticResourcesRecorder.java#L112-L115

geoand commented 1 year ago

Look like it!

Do you want a send a PR adding OPTIONS?

gsmet commented 1 year ago

Yeah, I'll have a look later today.

zenonwch commented 1 year ago

@gsmet maybe you can provide me with some workaround for the 2.16.5.Final version?

geoand commented 1 year ago

There isn't one

zenonwch commented 1 year ago

But as I see from the code source - there are no restrictions in the StaticResourcesRecorder for 2.16.5.Final version

image
geoand commented 1 year ago

You are right... Let me take a closer look

geoand commented 1 year ago

By the way, I still cannot access the reproducer link you provided. Please make sure it's not a private repo

zenonwch commented 1 year ago

Oops, sorry, my fault. Pls, try now.

geoand commented 1 year ago

It turns out this is a by design in Vert.x see

https://github.com/vert-x3/vertx-web/blob/4.3.7/vertx-web/src/main/java/io/vertx/ext/web/handler/impl/StaticHandlerImpl.java#L170

and

https://github.com/vert-x3/vertx-web/blob/4.4.1/vertx-web/src/main/java/io/vertx/ext/web/handler/impl/StaticHandlerImpl.java#L170

So there is not much we can do in Quarkus.

@cescoffier do we want to handle this in Vert.x or should this be closed as won't fix?

zenonwch commented 1 year ago

Thanks @geoand, I found this issue in the vertx-web project and it is still in Open status.

geoand commented 1 year ago

Cool, let's close this one then

zenonwch commented 1 year ago

That would be it I think: https://github.com/quarkusio/quarkus/blob/main/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/StaticResourcesRecorder.java#L112-L115

@gsmet I hope you will add OPTIONS to the accept method despite the issue being closed )).

quarkus-bot[bot] commented 1 year ago

@gastaldi triage/backport* labels may not be added to an issue. Please add them to the corresponding pull request.

This message is automatically generated by a bot.