{"record":{"id":"e83aea3c67a00925","repo":"quarkusio/quarkus","slug":"parameters-and-variables-don-t-match-on-typedef","errorCode":null,"errorMessage":"Parameters and variables don't match on ${typeDef}::${method}","messagePattern":"Parameters and variables don't match on (.+?)::(.+?)","errorType":"validation","errorClass":"RestClientDefinitionException","httpStatus":null,"severity":"error","filePath":"extensions/resteasy-classic/resteasy-client/runtime/src/main/java/io/quarkus/restclient/runtime/QuarkusRestClientBuilder.java","lineNumber":637,"sourceCode":"            Set<String> allVariables = new HashSet<>(template.getPathParamNamesInDeclarationOrder());\n            Map<String, Object> paramMap = new HashMap<>();\n            for (Parameter p : method.getParameters()) {\n                PathParam pathParam = p.getAnnotation(PathParam.class);\n                if (pathParam != null) {\n                    paramMap.put(pathParam.value(), \"foobar\");\n                } else if (p.isAnnotationPresent(org.jboss.resteasy.annotations.jaxrs.PathParam.class)) {\n                    org.jboss.resteasy.annotations.jaxrs.PathParam rePathParam = p\n                            .getAnnotation(org.jboss.resteasy.annotations.jaxrs.PathParam.class);\n                    String name = rePathParam.value() == null || rePathParam.value()\n                            .length() == 0 ? p.getName() : rePathParam.value();\n                    paramMap.put(name, \"foobar\");\n                } else if (p.isAnnotationPresent(BeanParam.class)) {\n                    verifyBeanPathParam(p.getType(), paramMap);\n                }\n            }\n\n            if (allVariables.size() != paramMap.size()) {\n                throw new RestClientDefinitionException(\n                        \"Parameters and variables don't match on \" + typeDef + \"::\" + method.getName());\n            }\n\n            try {\n                template.resolveTemplates(paramMap, false).build();\n            } catch (IllegalArgumentException ex) {\n                throw new RestClientDefinitionException(\n                        \"Parameter names don't match variable names on \" + typeDef + \"::\" + method.getName(), ex);\n            }\n\n        }\n    }\n\n    @Override\n    public Configuration getConfiguration() {\n        return getConfigurationWrapper();\n    }\n","sourceCodeStart":619,"sourceCodeEnd":655,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/resteasy-classic/resteasy-client/runtime/src/main/java/io/quarkus/restclient/runtime/QuarkusRestClientBuilder.java#L619-L655","documentation":"Thrown by verifyInterface during build as a RestClientDefinitionException when the @Path template variables (e.g. {id}) on a method don't match the set of @PathParam-annotated parameters. The number of declared path variables must equal the number of bound parameters.","triggerScenarios":"A @Path contains a variable like {id} but no matching @PathParam method parameter; an extra @PathParam with no corresponding {var} in the template; BeanParam fields counted separately causing count mismatch.","commonSituations":"Renaming a path segment but forgetting to rename the @PathParam; typos causing variable and param names to diverge; adding a @QueryParam mistakenly annotated as @PathParam.","solutions":["Make each {variable} in @Path have exactly one @PathParam with the same name, and vice versa","Remove unused @PathParam annotations or add the missing {var} to the @Path template","If a value isn't a path segment, annotate it @QueryParam/@HeaderParam instead"],"exampleFix":"// before\n@GET\n@Path(\"/items/{id}\")\nItem get(@PathParam(\"itemId\") String id); // mismatch\n// after\n@GET\n@Path(\"/items/{id}\")\nItem get(@PathParam(\"id\") String id);","handlingStrategy":"validation","validationCode":"// Check each {var} in @Path has a matching @PathParam of the same name\nPattern p = Pattern.compile(\"\\\\{([^}]+)\\\\}\");\nfor (Method m : MyClient.class.getMethods()) {\n    Path path = m.getAnnotation(Path.class);\n    if (path == null) continue;\n    Set<String> vars = new HashSet<>();\n    Matcher mm = p.matcher(path.value());\n    while (mm.find()) vars.add(mm.group(1));\n    Set<String> params = new HashSet<>();\n    for (java.lang.reflect.Parameter par : m.getParameters()) {\n        PathParam pp = par.getAnnotation(PathParam.class);\n        if (pp != null) params.add(pp.value());\n    }\n    if (!vars.equals(params)) throw new IllegalStateException(m + \": path vars \" + vars + \" != params \" + params);\n}","typeGuard":null,"tryCatchPattern":"try {\n    client = builder.build(MyClient.class);\n} catch (RestClientDefinitionException e) {\n    if (e.getMessage().contains(\"Parameters and variables don't match\")) {\n        log.error(\"Fix @Path templates vs @PathParam on: {}\", e.getMessage());\n    }\n    throw e;\n}","preventionTips":["Keep @PathParam values identical to {variable} names in @Path","Rename variable and annotation together (refactor tooling)","Don't use @PathParam for query values — use @QueryParam","Add a unit test that builds the client interface to fail fast"],"tags":["rest-client","interface-validation","path-param","rest-client-definition-exception"],"backgroundTag":"path-template-mismatch","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}