{"record":{"id":"a4ec0678cfccad72","repo":"quarkusio/quarkus","slug":"invalid-template-template","errorCode":null,"errorMessage":"Invalid template ${template}","messagePattern":"Invalid template (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/mapping/URITemplate.java","lineNumber":78,"sourceCode":"                        litChars++;\n                        sb.append(c);\n                    }\n                    break;\n                case 1:\n                    if (c == '}') {\n                        state = 0;\n                        if (sb.length() > 0) {\n                            capGroups++;\n                            if (i + 1 == template.length() || template.charAt(i + 1) == '/') {\n                                components\n                                        .add(new TemplateComponent(Type.DEFAULT_REGEX, null, sb.toString().trim(), null, null,\n                                                null));\n                            } else {\n                                components.add(new TemplateComponent(Type.CUSTOM_REGEX, \"[^/]+?\", sb.toString().trim(),\n                                        null, null, null));\n                            }\n                        } else {\n                            throw new IllegalArgumentException(\"Invalid template \" + template);\n                        }\n                        sb.setLength(0);\n                    } else if (c == ':') {\n                        name = sb.toString().trim();\n                        sb.setLength(0);\n                        state = 2;\n                    } else {\n                        sb.append(c);\n                    }\n                    break;\n                case 2:\n                    if (c == '}' && bracesCount == 0) {\n                        state = 0;\n                        if (sb.length() > 0) {\n                            capGroups++;\n                            complexGroups++;\n                            components\n                                    .add(new TemplateComponent(Type.CUSTOM_REGEX, sb.toString().trim(), name, null,","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/mapping/URITemplate.java#L60-L96","documentation":"URITemplate's constructor parses URI templates into path components. This IllegalArgumentException is thrown when a '{' segment containing a custom regex is malformed — e.g. a template like \"{id:regex(...)}\" whose inner expression does not match the expected custom-regex syntax, so the parser reaches an invalid state inside state 1.","triggerScenarios":"Declaring a path parameter with an invalid custom regex form in a URI template, e.g. @Path(\"/items/{id:regex(\") or an unrecognized special keyword after ':' inside braces that the parser cannot map to a TemplateComponent.","commonSituations":"Typos in custom regex declarations; copying templates from other frameworks (Spring/Spray syntax) unsupported here; unbalanced or unescaped regex characters inside braces; using unsupported syntax like {id: int} misspelled.","solutions":["Fix the template syntax inside braces; for custom regex use the form {name:regex(\"pattern\")} or {name:pattern} supported by the parser","Escape or remove characters inside the braces that break parsing (unmatched parens/brackets)","Simplify to a plain parameter {name} if no custom pattern is needed","Test the template string in a unit test constructing new URITemplate(...) to fail fast"],"exampleFix":"// before\n@Path(\"/items/{id:regex(\")\n\n// after\n@Path(\"/items/{id:regex(\"\\\\d+\")}\")","handlingStrategy":"validation","validationCode":"// validate template before use\nif (template.matches(\".*\\\\{[^}]*:regex\\\\([^)]*$\")) {\n    throw new IllegalArgumentException(\"Malformed custom regex in template: \" + template);\n}","typeGuard":null,"tryCatchPattern":"try {\n    new URITemplate(template);\n} catch (IllegalArgumentException e) {\n    throw new IllegalArgumentException(\"Fix @Path on resource class: \" + e.getMessage(), e);\n}","preventionTips":["Use the documented custom regex form {name:regex(\"pattern\")}","Test every custom @Path template in a unit test at build time","Avoid copy-pasting template syntax from other frameworks","Escape regex special characters inside patterns"],"tags":["routing","uri-template","regex","illegal-argument"],"backgroundTag":"invalid-uri-template","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"}