{"record":{"id":"dadaa5b2d6b7fe12","repo":"quarkusio/quarkus","slug":"illegal-uri-template-uritemplate","errorCode":null,"errorMessage":"Illegal URI template${uriTemplate}","messagePattern":"Illegal URI template(.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"independent-projects/resteasy-reactive/common/runtime/src/main/java/org/jboss/resteasy/reactive/common/jaxrs/UriBuilderImpl.java","lineNumber":182,"sourceCode":"            throw new IllegalArgumentException(\"Param was null\");\n        Matcher opaque = opaqueUri.matcher(uriTemplate);\n        if (opaque.matches()) {\n            this.authority = null;\n            this.host = null;\n            this.port = -1;\n            this.userInfo = null;\n            this.query = null;\n            this.scheme = opaque.group(1);\n            this.ssp = opaque.group(2);\n            return this;\n        } else {\n            Matcher match = hierarchicalUri.matcher(uriTemplate);\n            if (match.matches()) {\n                ssp = null;\n                return parseHierarchicalUri(uriTemplate, match);\n            }\n        }\n        throw new IllegalArgumentException(\"Illegal URI template\" + uriTemplate);\n    }\n\n    protected UriBuilder parseHierarchicalUri(CharSequence uriTemplate, Matcher match) {\n        boolean scheme = match.group(2) != null;\n        if (scheme)\n            this.scheme = match.group(2);\n        String authority = match.group(4);\n        if (authority != null) {\n            this.authority = null;\n            String host = match.group(4);\n            int at = host.indexOf('@');\n            if (at > -1) {\n                String user = host.substring(0, at);\n                host = host.substring(at + 1);\n                this.userInfo = user;\n            }\n\n            Matcher hostPortMatch = hostPortPattern.matcher(host);","sourceCodeStart":164,"sourceCodeEnd":200,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/resteasy-reactive/common/runtime/src/main/java/org/jboss/resteasy/reactive/common/jaxrs/UriBuilderImpl.java#L164-L200","documentation":"UriBuilderImpl.uriTemplate() throws this IllegalArgumentException when the given URI template matches neither the opaque-URI pattern nor the hierarchical-URI pattern used internally to parse templates. This is the RESTEasy Reactive implementation of the JAX-RS UriBuilder.uri(String) contract, which mandates IllegalArgumentException for malformed input. The message concatenates the offending template with no space, so it reads like 'Illegal URI templatehttp://...'.","triggerScenarios":"Calling uriTemplate/fromTemplate/uri/uriFromCharSequence/resolveTemplate(s)/resolveTemplateFromEncoded with a string matching neither internal regex: e.g. 'http:////bad', a scheme-only string like 'http:', or strings with characters illegal anywhere in a URI (unencoded spaces, stray brackets, unencoded braces outside template params).","commonSituations":"Base URLs from config or user input containing spaces or unencoded special characters; hand-concatenating scheme/authority parts; forgetting to URL-encode path/query values embedded in the template; framework upgrades tightening the parsing regexes.","solutions":["URI-encode variable parts (URLEncoder.encode with UTF-8) before calling uri()/uriTemplate()","Fix the configured base URL (e.g. quarkus.rest-client.*.url): remove spaces, stray brackets, double slashes","Build the URI with builder methods (scheme/host/port/path/queryParam) instead of one raw string","Catch IllegalArgumentException around uri()/uriTemplate() and log the offending template for diagnosis"],"exampleFix":"// before: UriBuilder.fromUri(userInput) throws for 'http://example .com' // after: String cleaned = userInput.trim().replace(' ', '%20'); URI uri = UriBuilder.fromUri(cleaned).build();","handlingStrategy":"validation","validationCode":"static void validateUriTemplate(String template) {\n    java.util.Objects.requireNonNull(template, 'template must not be null');\n    String t = template.trim();\n    if (t.isEmpty()) throw new IllegalArgumentException('template is empty');\n    if (t.contains(\" \")) throw new IllegalArgumentException('template contains unencoded space');\n    if (!t.matches('^[a-zA-Z][a-zA-Z0-9+.-]*:.*') && !t.startsWith('/'))\n        throw new IllegalArgumentException('template must include a scheme: ' + template);\n}","typeGuard":null,"tryCatchPattern":"try {\n    URI uri = UriBuilder.fromUri(template).build();\n} catch (IllegalArgumentException e) {\n    throw new IllegalArgumentException('Invalid URI template: ' + template, e);\n}","preventionTips":["Always include an explicit scheme (http:// or https://) in URI templates","URL-encode interpolated values with URLEncoder.encode before embedding","Validate configured base URLs at startup, not at first request","Never hand-concatenate scheme/host/port; use UriBuilder methods"],"tags":["resteasy-reactive","jaxrs","uri","illegal-argument"],"backgroundTag":"illegal-uri-template","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"}