Skip to content

Qute: require the index parameter for list get/take/takeLast - #56460

Merged
mkouba merged 1 commit into
quarkusio:mainfrom
MaxFreedomPollard:qute-list-index-parameter
Sep 15, 2026
Merged

mkouba merged 1 commit into
quarkusio:mainfrom
MaxFreedomPollard:qute-list-index-parameter

Conversation

@MaxFreedomPollard

Copy link
Copy Markdown
Contributor

{list.get}, {list.take} and {list.takeLast} render the first element of the list instead of failing. The switch in ValueResolvers.listResolveAsync() guards each of those three cases with if (context.getParams().size() == 1) and has nothing after the if, so when the index parameter is missing execution falls through to case ListResolver.FIRST and returns list.get(0). On an empty list the same fall-through throws a bare NoSuchElementException out of the render call.

Each case now returns a not-found result when there is no index parameter, so you get the usual Property "get" not found on the base object error instead. Arrays and maps already report an error here, and ListResolver.getSupportedProperties() only advertises first, last and the index, so get was never meant to resolve as a property.

The new test in ListResolverTest fails on main and passes with the change; ./mvnw install -f independent-projects/qute/ is green.

@quarkus-bot quarkus-bot Bot added the area/qute The template engine label Sep 6, 2026
@gsmet
gsmet requested a review from mkouba September 8, 2026 13:43

@mkouba mkouba left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

Could you pls verify if the same behavior applies in a regular Quarkus app, where CollectionTemplateExtensions is used instead? See also io.quarkus.qute.deployment.extensions.CollectionTemplateExtensionsTest.

@mkouba mkouba added the triage/waiting-for-ci Ready to merge when CI successfully finishes label Sep 9, 2026
@quarkus-bot

This comment has been minimized.

@mkouba

mkouba commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

@MaxFreedomPollard Could you pls squash the commits?

The switch in ValueResolvers.listResolveAsync() has no exit for the case
where get(), take() or takeLast() is used without exactly one parameter,
so execution falls through to the "first" case. As a result {list.get},
{list.take} and {list.takeLast} silently render the first element of the
list, and throw a bare NoSuchElementException when the list is empty.

Each of the three cases now returns a not-found result when the index
parameter is missing. That matches the array and map resolvers, which
already report an error, and it matches
ListResolver.getSupportedProperties(), which only advertises
get/take/takeLast as virtual methods taking an index.

Cover the fix in ListResolverTest, and pin the matching behaviour of a
Quarkus application in CollectionTemplateExtensionsTest, where the
generated value resolvers for CollectionTemplateExtensions already
require the index parameter.
@quarkus-bot

This comment has been minimized.

@quarkus-bot

This comment has been minimized.

@mkouba

mkouba commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

@MaxFreedomPollard The JVM Tests - JDK 25 Semeru failure might be related - it seems that quarkus-config-doc-maven-plugin is using Qute 🤔.

@MaxFreedomPollard

Copy link
Copy Markdown
Contributor Author

You are right that devtools/config-doc-maven-plugin depends on qute-core. That module's tests already ran green on Semeru with exactly this code: in attempt 2 of run 34483536314 (job 103306858514, same head sha 843f21e) the log shows Running io.quarkus.maven.config.doc.GenerateConfigDocMojoTest at 2026-09-11T19:35:08 followed by Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, and the reactor line Quarkus - Config doc Maven plugin .... SUCCESS [ 3.128 s]. That attempt failed in an unrelated module instead, at Quarkus - Reactive Microsoft SQL Server Client - Deployment FAILURE, when the mssql container exited during docker-maven-plugin:0.49.0:start.

In attempt 3 (job 103868355327) the fork died before it loaded a test class. Surefire printed T E S T S at 10:12:13.1856 and Tests run: 0, Failures: 0, Errors: 0, Skipped: 0 at 10:12:13.4897, with no Running ... line and no output from the fork at all. The Qute change itself ran green earlier in that same job on the same Semeru JDK: Running io.quarkus.qute.ListResolverTest at 05:30:06 then Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, and CollectionTemplateExtensionsTest 7/7 at 06:43:36. Those are the two tests this PR adds for the no-parameter case.

The module's only test class, GenerateConfigDocMojoTest, calls GenerateConfigDocMojo.findTargetDirectories and walks directories under a @TempDir, with no Qute reference, and none of the 15 templates under its src/main/resources/templates uses get, take or takeLast. I cannot say why the fork exited: there is no JVM diagnostic in the log, and the surefire dump files for that module are not in the build-reports or test-reports artifacts, which only contain a dumpstream for devtools/cli. Could someone re-run JVM Tests - JDK 25 Semeru on this commit?

@mkouba

mkouba commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

@MaxFreedomPollard I triggered a re-run for JVM Tests - JDK 25 Semeru. We'll see. Thanks!

@gsmet

gsmet commented Sep 15, 2026

Copy link
Copy Markdown
Member

Semeru tests are quite unstable. If all other JVM tests are passing, I would say go for it.

@quarkus-bot

quarkus-bot Bot commented Sep 15, 2026 •

Copy link
Copy Markdown

Status for workflow Quarkus CI

This is the status report for running Quarkus CI on commit 843f21e.

Failing Jobs

Status Name Step Failures Logs Raw logs Build scan
❌ Oracle Test Pilot 19c-atps - JDK 21 Build ⚠️ Check → Logs Raw logs 🚧
❌ PQC Tests Set up JDK 21 ⚠️ Check → Logs Raw logs 🚧

You can consult the Develocity build scans.


Flaky tests - Develocity

⚙️ JVM Tests - JDK 25 Semeru

📦 extensions/info/deployment

❌ io.quarkus.info.deployment.NoGitProjectInfoTest.test - History

  • 1 expectation failed. JSON path git doesn't match. Expected: is null Actual: <{branch=7dc2bc05803b53c0deb19b925629f185efd32e89, commit={id=7dc2bc05803b53c0deb19b925629f185efd32e89, time=2026-09-10T13:34:55Z}}> - java.lang.AssertionError
Details
java.lang.AssertionError: 
1 expectation failed.
JSON path git doesn't match.
Expected: is null
  Actual: <{branch=7dc2bc05803b53c0deb19b925629f185efd32e89, commit={id=7dc2bc05803b53c0deb19b925629f185efd32e89, time=2026-09-10T13:34:55Z}}>

	at org.codehaus.groovy.vmplugin.v8.IndyInterface.fromCache(IndyInterface.java:344)
	at io.restassured.internal.ResponseSpecificationImpl$HamcrestAssertionClosure.validate(ResponseSpecificationImpl.groovy:516)

@mkouba
mkouba merged commit a5e2465 into quarkusio:main Sep 15, 2026
199 of 207 checks passed
@quarkus-bot quarkus-bot Bot added this to the 4.0 - main milestone Sep 15, 2026
@quarkus-bot quarkus-bot Bot removed the triage/waiting-for-ci Ready to merge when CI successfully finishes label Sep 15, 2026

This branch was previously deployed

1 inactive deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants