{"record":{"id":"4f4f63a681362808","repo":"quarkusio/quarkus","slug":"n-th-parameter-is-missing","errorCode":null,"errorMessage":"n-th parameter is missing","messagePattern":"n-th parameter is missing","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"independent-projects/qute/core/src/main/java/io/quarkus/qute/ValueResolvers.java","lineNumber":406,"sourceCode":"        static final String GET = \"get\";\n\n        public ArrayResolver() {\n            super(Set.of(LENGTH, SIZE, \"${index}\"), //\n                    Set.of(TAKE + \"(${index})\", TAKE_LAST + \"(${index})\", GET + \"(${index})\"));\n        }\n\n        public boolean appliesTo(EvalContext context) {\n            return context.getBase() != null && context.getBase().getClass().isArray();\n        }\n\n        @Override\n        public CompletionStage<Object> resolve(EvalContext context) {\n            String name = context.getName();\n            if (name.equals(LENGTH) || name.equals(SIZE)) {\n                return CompletedStage.of(Array.getLength(context.getBase()));\n            } else if (name.equals(TAKE)) {\n                if (context.getParams().isEmpty()) {\n                    throw new IllegalArgumentException(\"n-th parameter is missing\");\n                }\n                Expression indexExpr = context.getParams().get(0);\n                if (indexExpr.isLiteral()) {\n                    Object literalValue = indexExpr.getLiteral();\n                    if (literalValue instanceof Integer) {\n                        return CompletedStage.of(takeArray((Integer) literalValue, context.getBase()));\n                    }\n                    return Results.notFound(context);\n                } else {\n                    return context.evaluate(indexExpr).thenCompose(n -> {\n                        if (n instanceof Integer) {\n                            return CompletedStage.of(takeArray((Integer) n, context.getBase()));\n                        }\n                        return Results.notFound(context);\n                    });\n                }\n            } else if (name.equals(TAKE_LAST)) {\n                if (context.getParams().isEmpty()) {","sourceCodeStart":388,"sourceCodeEnd":424,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/qute/core/src/main/java/io/quarkus/qute/ValueResolvers.java#L388-L424","documentation":"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\").","triggerScenarios":"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.","commonSituations":"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.","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}."],"exampleFix":"// before (template)\n{items.take}\n\n// after (template)\n{items.take(3)}","handlingStrategy":"validation","validationCode":"// in template data, before rendering, ensure the argument exists:\nif (count == null) {\n    throw new IllegalStateException(\"take(n) requires a count parameter\");\n}","typeGuard":"static boolean hasTakeParams(String expr) {\n    return expr.matches(\".*\\\\.take\\\\s*\\\\(.+\\\\).*\");\n}","tryCatchPattern":"try {\n    // render template that uses take\n} catch (IllegalArgumentException e) {\n    if (\"n-th parameter is missing\".equals(e.getMessage())) {\n        // fix expression to pass an index: items.take(n)\n    } else {\n        throw e;\n    }\n}","preventionTips":["Always pass an explicit index to take(), literal or variable","Verify dynamic parameters resolve before rendering","Add template tests covering array take expressions"],"tags":["qute","value-resolver","illegal-argument","arrays","missing-parameter"],"backgroundTag":"missing-method-parameter","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}