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

Qute template extensions throw ambiguous exception on property not found #22931

Closed
thienldd opened this issue Jan 17, 2022 · 1 comment · Fixed by #22935
Closed

Qute template extensions throw ambiguous exception on property not found #22931

thienldd opened this issue Jan 17, 2022 · 1 comment · Fixed by #22935
Assignees
Labels
area/qute The template engine kind/bug Something isn't working
Milestone

Comments

@thienldd
Copy link

Describe the bug

"{time:format(input.birthday, 'uuuu')}" throw IllegalStateException without any meaningful message in case the "birthday" property does not exist.

Expected behavior

should convey meaningful message similar to what {input.birthday} will throw:

`io.quarkus.qute.TemplateException: Property "birthday" not found on the base object "java.util.ImmutableCollections$Map1" in expression {input.birthday} in template 1 on line 1

at io.quarkus.qute.EvaluatorImpl.propertyNotFound(EvaluatorImpl.java:208)
at io.quarkus.qute.EvaluatorImpl.resolve(EvaluatorImpl.java:169)
at io.quarkus.qute.EvaluatorImpl.lambda$resolve$4(EvaluatorImpl.java:179)
at io.quarkus.qute.CompletedStage.thenCompose(CompletedStage.java:228)
at io.quarkus.qute.EvaluatorImpl.resolve(EvaluatorImpl.java:176)
at io.quarkus.qute.EvaluatorImpl.resolveReference(EvaluatorImpl.java:113)
at io.quarkus.qute.EvaluatorImpl.lambda$resolveReference$2(EvaluatorImpl.java:117)
at io.quarkus.qute.CompletedStage.thenCompose(CompletedStage.java:228)
at io.quarkus.qute.EvaluatorImpl.resolveReference(EvaluatorImpl.java:117)
at io.quarkus.qute.EvaluatorImpl.evaluate(EvaluatorImpl.java:81)
at io.quarkus.qute.ResolutionContextImpl.evaluate(ResolutionContextImpl.java:28)
at io.quarkus.qute.ExpressionNode.resolve(ExpressionNode.java:25)
at io.quarkus.qute.SectionNode$SectionResolutionContextImpl.execute(SectionNode.java:149)
at io.quarkus.qute.SectionHelper$SectionResolutionContext.execute(SectionHelper.java:37)
at io.quarkus.qute.Parser$1.resolve(Parser.java:1054)
at io.quarkus.qute.SectionNode.resolve(SectionNode.java:34)
at io.quarkus.qute.TemplateImpl$TemplateInstanceImpl.renderData(TemplateImpl.java:104)
at io.quarkus.qute.TemplateImpl$TemplateInstanceImpl.renderAsync(TemplateImpl.java:90)
at io.quarkus.qute.TemplateImpl$TemplateInstanceImpl.render(TemplateImpl.java:55)
at TimeTemplateExtensionsTest.test(TimeTemplateExtensionsTest.java:33)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at io.quarkus.test.junit.QuarkusTestExtension.runExtensionMethod(QuarkusTestExtension.java:956)
at io.quarkus.test.junit.QuarkusTestExtension.interceptTestMethod(QuarkusTestExtension.java:776)
at org.junit.jupiter.engine.execution.ExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(ExecutableInvoker.java:115)
at org.junit.jupiter.engine.execution.ExecutableInvoker.lambda$invoke$0(ExecutableInvoker.java:105)
at org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:106)
at org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:149)
at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestableMethod(TimeoutExtension.java:140)
at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestMethod(TimeoutExtension.java:84)
at org.junit.jupiter.engine.execution.ExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(ExecutableInvoker.java:115)
at org.junit.jupiter.engine.execution.ExecutableInvoker.lambda$invoke$0(ExecutableInvoker.java:105)
at org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:106)
at org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:64)
at org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java:45)
at org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke(InvocationInterceptorChain.java:37)
at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:104)
at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:98)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$7(TestMethodTestDescriptor.java:214)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod(TestMethodTestDescriptor.java:210)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:135)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:66)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:151)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:35)
at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:54)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:107)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:88)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:54)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:67)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:52)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:114)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:86)
at org.junit.platform.launcher.core.DefaultLauncherSession$DelegatingLauncher.execute(DefaultLauncherSession.java:86)
at org.junit.platform.launcher.core.SessionPerRequestLauncher.execute(SessionPerRequestLauncher.java:53)
at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:71)
at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38)
at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11)
at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35)
at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235)
at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)`

Actual behavior

Caused by: java.lang.IllegalStateException: java.util.concurrent.TimeoutException at io.quarkus.qute.TemplateImpl$TemplateInstanceImpl.render(TemplateImpl.java:60) at TimeTemplateExtensionsTest.lambda$throwAmbiguousExceptionOnPropertyNotFound$0(TimeTemplateExtensionsTest.java:23) at org.junit.jupiter.api.AssertThrows.assertThrows(AssertThrows.java:55) ... 74 more Caused by: java.util.concurrent.TimeoutException at java.base/java.util.concurrent.CompletableFuture.timedGet(CompletableFuture.java:1886) at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:2021) at io.quarkus.qute.TemplateImpl$TemplateInstanceImpl.render(TemplateImpl.java:55) ... 76 more

How to Reproduce?

Please look at the test class TimeTemplateExtensionsTest
test-quarkus.zip

Output of uname -a or ver

No response

Output of java -version

openjdk 11

GraalVM version (if different from Java)

No response

Quarkus version or git rev

Quarkus 2.6.2.Final

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

No response

Additional information

No response

@thienldd thienldd added the kind/bug Something isn't working label Jan 17, 2022
@quarkus-bot
Copy link

quarkus-bot bot commented Jan 17, 2022

/cc @mkouba

@quarkus-bot quarkus-bot bot added the area/qute The template engine label Jan 17, 2022
@mkouba mkouba self-assigned this Jan 17, 2022
@mkouba mkouba added this to the 2.7 - main milestone Jan 17, 2022
mkouba added a commit to mkouba/quarkus that referenced this issue Jan 17, 2022
@gsmet gsmet modified the milestones: 2.7 - main, 2.6.3.Final Jan 18, 2022
gsmet pushed a commit to gsmet/quarkus that referenced this issue Jan 18, 2022

Verified

This commit was signed with the committer’s verified signature.
gsmet Guillaume Smet
- resolves quarkusio#22931

(cherry picked from commit 44d28dc)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/qute The template engine kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants