quarkusio/quarkus · error · IllegalArgumentException
n-th parameter is missing
Error message
n-th parameter is missing
What it means
Qute's ArrayResolver supports the array 'take' method (take(n) returns the first n elements). If the expression provides no parameters, resolver throws IllegalArgumentException("n-th parameter is missing").
Source
Thrown at independent-projects/qute/core/src/main/java/io/quarkus/qute/ValueResolvers.java:406
static final String GET = "get";
public ArrayResolver() {
super(Set.of(LENGTH, SIZE, "${index}"), //
Set.of(TAKE + "(${index})", TAKE_LAST + "(${index})", GET + "(${index})"));
}
public boolean appliesTo(EvalContext context) {
return context.getBase() != null && context.getBase().getClass().isArray();
}
@Override
public CompletionStage<Object> resolve(EvalContext context) {
String name = context.getName();
if (name.equals(LENGTH) || name.equals(SIZE)) {
return CompletedStage.of(Array.getLength(context.getBase()));
} else if (name.equals(TAKE)) {
if (context.getParams().isEmpty()) {
throw new IllegalArgumentException("n-th parameter is missing");
}
Expression indexExpr = context.getParams().get(0);
if (indexExpr.isLiteral()) {
Object literalValue = indexExpr.getLiteral();
if (literalValue instanceof Integer) {
return CompletedStage.of(takeArray((Integer) literalValue, context.getBase()));
}
return Results.notFound(context);
} else {
return context.evaluate(indexExpr).thenCompose(n -> {
if (n instanceof Integer) {
return CompletedStage.of(takeArray((Integer) n, context.getBase()));
}
return Results.notFound(context);
});
}
} else if (name.equals(TAKE_LAST)) {
if (context.getParams().isEmpty()) {View on GitHub (pinned to e1c734241f)
Solutions
- Pass a literal or expression index: {myArray.take(3)}.
- If the index comes from a variable, verify it resolves and is passed as a parameter: {myArray.take(count)}.
- Guard the template: only call take when a count is available, e.g. {#if count}{myArray.take(count)}{/if}.
Example fix
// before (template)
{items.take}
// after (template)
{items.take(3)} Defensive patterns
Strategy: validation
Validate before calling
// in template data, before rendering, ensure the argument exists:
if (count == null) {
throw new IllegalStateException("take(n) requires a count parameter");
} Type guard
static boolean hasTakeParams(String expr) {
return expr.matches(".*\\.take\\s*\\(.+\\).*");
} Try / catch
try {
// render template that uses take
} catch (IllegalArgumentException e) {
if ("n-th parameter is missing".equals(e.getMessage())) {
// fix expression to pass an index: items.take(n)
} else {
throw e;
}
} Prevention
- Always pass an explicit index to take(), literal or variable
- Verify dynamic parameters resolve before rendering
- Add template tests covering array take expressions
When it happens
Trigger: Evaluating an expression like {myArray.take} or take() with an empty/missing argument in a template, where context.getParams() is empty for the TAKE method name.
Common situations: Typos such as writing take without parentheses-argument, dynamically built expressions where the index variable failed to render/resolve to a parameter, copy-pasted templates missing the argument.
Related errors
- Invalid identifier found: [id]
- Literal must not be null
- Only Latin characters are supported:
- Replacement ID must be in range [0, 15] but was:
- Unexpected tag: " + tag
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/4f4f63a681362808.
Report an issue: GitHub.