{"record":{"id":"a87b573751e71c03","repo":"quarkusio/quarkus","slug":"template-parm-was-null","errorCode":null,"errorMessage":"Template parm was null: ","messagePattern":"Template parm was null: ","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":694,"sourceCode":"                if (isTemplate) {\n                    builder.append(matcher.group());\n                    start = matcher.end();\n                    continue;\n                }\n                throw new IllegalArgumentException(\"Path parameter not provided \" + param);\n            }\n            Object value = paramMap.get(param);\n            String stringValue = value != null ? value.toString() : null;\n            if (stringValue != null) {\n                if (!fromEncodedMap) {\n                    stringValue = Encode.encodeQueryParamAsIs(stringValue);\n                } else {\n                    stringValue = Encode.encodeQueryParamSaveEncodings(stringValue);\n                }\n                builder.append(stringValue);\n                start = matcher.end();\n            } else {\n                throw new IllegalArgumentException(\"Template parm was null: \" + param);\n            }\n        }\n        builder.append(string, start, string.length());\n        return builder;\n    }\n\n    /**\n     * Return a unique order list of path params.\n     *\n     * @return list of path parameters\n     */\n    public List<String> getPathParamNamesInDeclarationOrder() {\n        List<String> params = new ArrayList<String>();\n        HashSet<String> set = new HashSet<String>();\n        if (scheme != null)\n            addToPathParamList(params, set, scheme);\n        if (userInfo != null)\n            addToPathParamList(params, set, userInfo);","sourceCodeStart":676,"sourceCodeEnd":712,"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#L676-L712","documentation":"IllegalArgumentException thrown from the query-parameter replacement method when the value looked up for a {placeholder} in a query template is null. It is the query-string sibling of 'Template parameter null': the key resolved (or was present) but the value is null, so no valid substitution exists for a concrete URI.","triggerScenarios":"build(Object... values) / buildFromValues where one of the values for a {token} in a queryParam template string is null; the count matched but an element was null, so URITemplateParametersMap yields null for that param.","commonSituations":"Passing nullable variables directly as varargs: build(term) where term is null; Optional handling that unwraps to null; test fixtures with missing data; bean properties that are null at call time.","solutions":["Null-check every varargs value before build() and substitute a default (e.g. empty string) where semantically valid","Unwrap Optionals with orElseThrow instead of orElse(null) when the parameter is required","Conditionally add the queryParam only when the value is non-null, keeping the template free of that {token}","Wrap build() in a helper that validates values and rethrows with the parameter name for diagnosis"],"exampleFix":"// before\nURI u = UriBuilder.fromUri(\"/search\").queryParam(\"q\", \"{term}\").build(term); // term may be null\n// after\nURI u = term == null\n    ? UriBuilder.fromUri(\"/search\").build()\n    : UriBuilder.fromUri(\"/search\").queryParam(\"q\", term).build();","handlingStrategy":"validation","validationCode":"for (Object v : values) { if (v == null) throw new IllegalArgumentException(\"URI template values must be non-null\"); }\nURI uri = builder.build(values);","typeGuard":"static boolean allNonNull(Object[] values) { return values != null && java.util.Arrays.stream(values).allMatch(java.util.Objects::nonNull); }","tryCatchPattern":"try {\n    URI uri = builder.build(values);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().startsWith(\"Template parm was null\")) {\n        throw new IllegalStateException(\"Null value in URI template varargs: \" + e.getMessage(), e);\n    }\n    throw e;\n}","preventionTips":["Unwrap Optionals with orElseThrow, not orElse(null), before varargs build","Conditionally add optional query params instead of passing null placeholders","Null-check varargs arrays at API boundaries before forwarding to UriBuilder"],"tags":["uri","resteasy-reactive","null-value","query-param"],"backgroundTag":"missing-uri-template-parameter","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"}