quarkusio / quarkus

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

Accessing DevConsole fails with InternalServerError in the current snapshot #18413

Closed sberyozkin closed 3 years ago

sberyozkin commented 3 years ago

Describe the bug

Starting the quickstarts (I've tried security-openid-connect-quickstart followed by getting-started) with mvn quarkus:dev and then accessing the console from the browser at localhost:8080/q/dev fails with:

io.quarkus.qute.TemplateException: Property "currentExtensionName" not found in expression {currentExtensionName} in template main on line 25
    at io.quarkus.qute.EvaluatorImpl.propertyNotFound(EvaluatorImpl.java:207)
        ...
    at io.quarkus.qute.TemplateImpl$TemplateInstanceImpl.renderAsync(TemplateImpl.java:90)
    at io.quarkus.vertx.http.deployment.devmode.console.DevConsole.renderTemplate(DevConsole.java:134)
    at io.quarkus.vertx.http.deployment.devmode.console.DevConsole.sendMainPage(DevConsole.java:178)
    at io.quarkus.vertx.http.deployment.devmode.console.DevConsole.handle(DevConsole.java:97)
    at io.quarkus.vertx.http.deployment.devmode.console.DevConsole.handle(DevConsole.java:34)
    at io.vertx.ext.web.impl.RouteState.handleContext(RouteState.java:1127)
    at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:151)
    at io.vertx.ext.web.impl.RoutingContextWrapper.next(RoutingContextWrapper.java:201)
    at io.quarkus.vertx.http.deployment.devmode.console.FlashScopeHandler.handle(FlashScopeHandler.java:12)
    at io.quarkus.vertx.http.deployment.devmode.console.FlashScopeHandler.handle(FlashScopeHandler.java:7)
    at io.vertx.ext.web.impl.RouteState.handleContext(RouteState.java:1127)
    at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:151)
    ...
    at io.vertx.ext.web.impl.RouterImpl.handle(RouterImpl.java:37)
    at io.quarkus.vertx.http.deployment.devmode.console.DevConsoleProcessor$2$1.handle(DevConsoleProcessor.java:195)
    at io.quarkus.vertx.http.deployment.devmode.console.DevConsoleProcessor$2$1.handle(DevConsoleProcessor.java:192)
    at io.vertx.core.impl.EventLoopContext.emit(EventLoopContext.java:49)
    at io.vertx.core.impl.EventLoopContext.lambda$emit$1(EventLoopContext.java:56)

CC @stuartwdouglas @phillip-kruger

gastaldi commented 3 years ago

This may be caused by https://github.com/quarkusio/quarkus/pull/18227, I think the quickstarts need to be updated accordingly? /cc @mkouba

sberyozkin commented 3 years ago

It is probably the DevServices console code in Quarkus which should pass io.quarkus.qute.strict-rendering=false to Qute;

Or maybe the fact it is rendered async is what causes the problem ?

phillip-kruger commented 3 years ago

If no-one else is looking at this, I can have a look.

phillip-kruger commented 3 years ago

Adding strictRendering(false) fix it. Not sure if that is the correct fix. I'll do a PR and we can discuss there ?

mkouba commented 3 years ago

Ok, so the problem is that the data map has no key of value currentExtensionName. We only add this to the data for non-main templates: https://github.com/quarkusio/quarkus/blob/main/extensions/vertx-http/deployment/src/main/java/io/quarkus/vertx/http/deployment/devmode/console/DevConsole.java#L111. Like I mentioned in https://github.com/quarkusio/quarkus/pull/18416#issuecomment-875517107 it wouldn't be a problem if it was null.

So there are several ways how to fix this: 1) add .data("currentExtensionName", null) even for the main page, 2) disable strict rendering, 3) modify the {#if currentExtensionName} to something like: a. {#if containsKey('currentExtensionName')} -> this would work because the root data object is a map b. {#if currentExtensionName.or(false)} -> this would return false for "not found" and null values

phillip-kruger commented 3 years ago

@mkouba what do you suggest ?

mkouba commented 3 years ago

Well, the option 1 is quick but fixes only the problem with the main template. Option 2 is a safe one because we don't have tests for all DEV UI pages and more of them could be broken. On the other hand, option 2 is a bit short-sighted. Option 3 is a bit cumbersome. I think that for now we should go with option 2.

I will create a separate issue to verify all DEV UI templates and possibly switch to strict rendering afterwards.

BTW I think that we should definitely improve the error message for this particular case (i.e. data map is missig a binding) and provide something less cumbersome to check the "not found" value in the {#if} section.

phillip-kruger commented 3 years ago

So we should merge #18416 (option 2) for now ?