-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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 - introduce strict rendering #18227
Conversation
Note that this is a breaking change - the default behavior has changed. Type-safe templates are not affected though. This PR is related to #18177. |
b9b07fd
to
0a87ec6
Compare
@@ -50,6 +50,8 @@ public static String readQuteFile(CodestartResource projectResource, Source sour | |||
final Engine engine = Engine.builder().addDefaults() | |||
.addResultMapper(new MissingValueMapper()) | |||
.removeStandaloneLines(true) | |||
// TODO This needs to be revisited | |||
.strictRendering(false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI @ia3andy
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so what cases is it that you see that will break here ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not examine the failures but a lot of codestarts and devtools tests failed so it's definitely related. A quick scan example: "Property "parent" not found on base object "java.util.HashMap" in expression {parent} in template 1 on line 6" in theQuarkusExtensionCodestartGenerationTest
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
interesting - now curious which of these are actual bugs.
should map lookups be considered valid or is expectation you do {obj.parent ? false} ?
sucks we didnt notice this before 2.0 :/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll need to take a look at the tests. But it can be a bug in the test too ;-).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I checked the tests and the problematic pattern looks like {#if uberjar}<quarkus.package.type>uber-jar</quarkus.package.type>{/if}
. Previously this didn't fail because "not found" was considered a falsy
value. In this PR, we assume that "not found" cannot be evaluated correctly by default and thus the rendering fails. Note that null
would be OK because it means that we found something...
With strict rendering enabled the template would have to use something like {#if uberjar.or(false)}
(elvis operator would not work here because it's a param of a section) or even {#if containsKey('uberjar')}
(because the data object is a manually created Map
).
That said, I think it's ok to disable the strict rendering for situations like these. I'll let @ia3andy to decide later. For now, I will add a more explaining comment.
should map lookups be considered valid or is expectation you do {obj.parent ? false} ?
I don't think we should add a special handling for any type. That might be even more confusing.
0a87ec6
to
cdffad4
Compare
I'm not sure. What's the rationale for changing the default in the case of non-type-safe templates? Seems to me that they're not type-safe so why throw? 🤷 |
So the main motivation is to help users to spot the problems with typos and similar kind of errors. Of course, this change does not affect users of For example, a template without type-safe checks: Note that before this PR it was possible to change the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
To be clear my main ask is that qute stand-alone at least don't let obvious errors be ignored. Ie. Typos In if statements. Should at least be possible to enable. |
cdffad4
to
d6a771a
Compare
b679712
to
cabafef
Compare
This workflow status is outdated as a new workflow run has been triggered. Failing Jobs - Building cabafef
Full information is available in the Build summary check run. Test Failures⚙️ JVM Tests - JDK 11 #📦 extensions/vertx-http/deployment✖ |
cabafef
to
ecb7b62
Compare
Hm, I can see the following failure in JVM Tests - JDK 16:
|
Huh.... I don't see that in #18222 for example that was rebased onto the new Kotlin layout |
This workflow status is outdated as a new workflow run has been triggered. |
#18353 should fix the CI |
- i.e. if any expression is evaluated to "not found" value a TemplateException is thrown and rendering is aborted - it's enabled by default - it can be disabled via io.quarkus.qute.strict-rendering=false
ecb7b62
to
f76ba44
Compare
TemplateException is thrown and rendering is aborted