{"record":{"id":"c10a098751ee7a54","repo":"quarkusio/quarkus","slug":"param-was-null-c10a09","errorCode":null,"errorMessage":"Param was null","messagePattern":"Param was null","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"warning","filePath":"independent-projects/resteasy-reactive/common/runtime/src/main/java/org/jboss/resteasy/reactive/common/jaxrs/UriBuilderImpl.java","lineNumber":164,"sourceCode":"    public static UriBuilderImpl fromTemplate(String uriTemplate) {\n        UriBuilderImpl impl = (UriBuilderImpl) RuntimeDelegate.getInstance().createUriBuilder();\n        impl.uriTemplate(uriTemplate);\n        return impl;\n    }\n\n    private static final Pattern hostPortPattern = Pattern.compile(\"([^/:]+):(\\\\d+)\");\n    private static final Pattern squareHostBrackets = Pattern\n            .compile(\"(\\\\[(([0-9A-Fa-f]{0,4}:){2,7})([0-9A-Fa-f]{0,4})%?.*\\\\]):(\\\\d+)\");\n\n    /**\n     * You may put path parameters anywhere within the uriTemplate except port.\n     *\n     * @param uriTemplate uri template\n     * @return uri builder\n     */\n    public UriBuilder uriTemplate(CharSequence uriTemplate) {\n        if (uriTemplate == null)\n            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);","sourceCodeStart":146,"sourceCodeEnd":182,"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#L146-L182","documentation":"UriBuilderImpl.uriTemplate validates its input and throws IllegalArgumentException('Param was null') when the given URI template CharSequence is null, per the JAX-RS UriBuilder contract which forbids null template strings.","triggerScenarios":"Passing null to UriBuilder.fromTemplate(null), uri(null), uriFromCharSequence(null), or resolveTemplates/resolveTemplate/resolveTemplateFromEncoded with a null template; commonly a null variable that was interpolated into a template argument.","commonSituations":"Building client URLs from configuration values that are unset (null base URI); resolveTemplate with a variable that failed lookup; Optional value not unwrapped before building a URI.","solutions":["Null-check or default the template/variable before passing it to UriBuilder","If the value comes from config, validate it at startup (fail fast on missing property)","Use Optional.map/orElse to supply a safe default before building the URI","Wrap URI construction in try-catch (IllegalArgumentException) when input is user/environment-derived"],"exampleFix":"// before\nString base = config.baseUrl(); // may be null\nURI u = UriBuilder.fromUri(base).path(\"/api\").build(); // IllegalArgumentException\n// after\nObjects.requireNonNull(config.baseUrl(), \"baseUrl config must be set\");\nURI u = UriBuilder.fromUri(config.baseUrl()).path(\"/api\").build();","handlingStrategy":"validation","validationCode":"Objects.requireNonNull(template, \"URI template must not be null\");\n// or for variables:\ntemplates.values().removeIf(Objects::isNull);","typeGuard":"boolean validTemplate(CharSequence t) { return t != null && !t.toString().isBlank(); }","tryCatchPattern":"try {\n    return UriBuilder.fromUri(template).path(path).build();\n} catch (IllegalArgumentException e) {\n    log.error(\"Invalid URI input: \" + e.getMessage());\n    return null;\n}","preventionTips":["Validate config-provided base URIs at startup","Never pass Optional.get() of an empty Optional into UriBuilder","Default missing template variables before resolution","Fail fast with requireNonNull on user-supplied URI parts"],"tags":["jaxrs","uri-builder","illegal-argument","null-check"],"backgroundTag":"null-argument-validation","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"}