{"record":{"id":"eeac00415bd79e7c","repo":"quarkusio/quarkus","slug":"class-method-must-declare-a-parameter-of-nam","errorCode":null,"errorMessage":"<Class>#<method>() must declare a parameter of name [<paramName>] and type [<type>]","messagePattern":"<Class>#<method>\\(\\) must declare a parameter of name \\[<paramName>\\] and type \\[<type>\\]","errorType":"exception","errorClass":"io.quarkus.qute.TemplateException","httpStatus":null,"severity":"error","filePath":"extensions/qute/deployment/src/main/java/io/quarkus/qute/deployment/QuteProcessor.java","lineNumber":963,"sourceCode":"                            }\n                        }\n                    }\n                }\n            }\n            if (!paramNamesToTypes.isEmpty()) {\n                for (Entry<String, Type> e : paramNamesToTypes.entrySet()) {\n                    String paramName = e.getKey();\n                    MethodInfo methodOrConstructor = null;\n                    if (validation.checkedTemplate.isRecord()) {\n                        methodOrConstructor = validation.checkedTemplate.recordClass\n                                .canonicalRecordConstructor();\n                    } else {\n                        methodOrConstructor = validation.checkedTemplate.method;\n                    }\n                    MethodParameterInfo param = methodOrConstructor.parameters().stream()\n                            .filter(mp -> mp.name().equals(paramName)).findFirst().orElse(null);\n                    if (param == null || !assignabilityCheck.isAssignableFrom(e.getValue(), param.type())) {\n                        throw new TemplateException(\n                                validation.checkedTemplate.method.declaringClass().name().withoutPackagePrefix() + \"#\"\n                                        + validation.checkedTemplate.method.name() + \"() must declare a parameter of name [\"\n                                        + paramName\n                                        + \"] and type [\" + e.getValue() + \"]\");\n                    }\n                }\n            }\n        }\n    }\n\n    @BuildStep(onlyIf = IsTest.class)\n    SyntheticBeanBuildItem registerRenderedResults(QuteConfig config) {\n        if (config.testMode().recordRenderedResults()) {\n            return SyntheticBeanBuildItem.configure(RenderedResults.class)\n                    .unremovable()\n                    .scope(Singleton.class)\n                    .creator(RenderedResultsCreator.class)\n                    .done();","sourceCodeStart":945,"sourceCodeEnd":981,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/qute/deployment/src/main/java/io/quarkus/qute/deployment/QuteProcessor.java#L945-L981","documentation":"Thrown during validation of type-safe templates/fragments when a template parameter key or checked fragment parameter cannot be matched to a method parameter of the @CheckedTemplate method/constructor, or the declared types are not assignable. Qute type-checks template data against the parameters of the checked template method.","triggerScenarios":"The template references a data key (e.g. {name}) for which the @CheckedTemplate method declares no parameter with that name; a parameter exists but its type is not assignable from the value type recorded in the template validation; parameter name info lost at compile time so names do not match.","commonSituations":"Adding a new data key to a template without adding the corresponding method parameter; renaming a Java parameter but not the template; compiling without -parameters so parameter names differ; passing a subtype/supertype mismatch in a fragment validation.","solutions":["Add or rename the @CheckedTemplate method parameter so its name exactly matches the key used in the template","Make the declared parameter type assignable from the value type used in the template expression","If the mismatch is intentional, adjust the template to use the declared parameter name/type","Compile with -parameters (Quarkus does by default) so method parameter names are preserved for matching"],"exampleFix":"// before\n@CheckedTemplate\nstatic class Templates {\n    public static native TemplateInstance page(String userName); // template uses {name}\n}\n\n// after\n@CheckedTemplate\nstatic class Templates {\n    public static native TemplateInstance page(String name); // matches {name} in page.html\n}","handlingStrategy":"validation","validationCode":"// Ensure every data key used in the template has a matching method parameter\nSet<String> paramNames = method.parameters().stream().map(p -> p.name()).collect(Collectors.toSet());\nSet<String> templateKeys = extractKeys(templateBody); // e.g. {name}, {item:price}\ntemplateKeys.removeAll(paramNames);\nif (!templateKeys.isEmpty()) { throw new IllegalStateException(\"Missing params: \" + templateKeys); }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Add the method parameter first, then use it in the template","Use type-safe checked templates instead of string-based data maps","Avoid renaming parameters without grepping the template for the old name","Keep -parameters compilation enabled (Quarkus default)"],"tags":["quarkus","qute","type-safety","checked-template"],"backgroundTag":"template-parameter-mismatch","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"}