{"record":{"id":"98afb97649e3784b","repo":"keycloak/keycloak","slug":"values-parameter-is-null","errorCode":null,"errorMessage":"values parameter is null","messagePattern":"values parameter is null","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"common/src/main/java/org/keycloak/common/util/KeycloakUriBuilder.java","lineNumber":661,"sourceCode":"        if (fragment != null) addToPathParamList(params, set, fragment);\n\n        return params;\n    }\n\n    private void addToPathParamList(List<String> params, HashSet<String> set, String string) {\n        Matcher matcher = PathHelper.URI_PARAM_PATTERN.matcher(PathHelper.replaceEnclosedCurlyBraces(string));\n        while (matcher.find()) {\n            String param = matcher.group(1);\n            if (set.contains(param)) continue;\n            else {\n                set.add(param);\n                params.add(param);\n            }\n        }\n    }\n\n    public URI build(Object... values) throws IllegalArgumentException {\n        if (values == null) throw new IllegalArgumentException(\"values parameter is null\");\n        return buildFromValues(true, false, values);\n    }\n\n    public String buildAsString(Object... values) throws IllegalArgumentException {\n        if (values == null) throw new IllegalArgumentException(\"values parameter is null\");\n        return buildFromValuesAsString(true, false, values);\n    }\n\n    protected URI buildFromValues(boolean encodeSlash, boolean encoded, Object... values) {\n        String buf = buildFromValuesAsString(encodeSlash, encoded, values);\n        try {\n            return new URI(buf);\n        } catch (Exception e) {\n            throw new RuntimeException(\"Failed to create URI: \" + buf, e);\n        }\n    }\n\n    protected String buildFromValuesAsString(boolean encodeSlash, boolean encoded, Object... values) {","sourceCodeStart":643,"sourceCodeEnd":679,"githubUrl":"https://github.com/keycloak/keycloak/blob/66c7e15a3788de7764f07dd2558275a02770e16d/common/src/main/java/org/keycloak/common/util/KeycloakUriBuilder.java#L643-L679","documentation":"Guard at the top of build(Object... values): the varargs array itself is null. Calling build() with NO arguments yields an empty array, not null, so this only triggers when a caller passes an explicit null array - typically build((Object[]) null) or a null Object[] variable. Distinct from a null element inside the array (that is error 171).","triggerScenarios":"Object[] args = computeArgs(); builder.build(args); where computeArgs() returned null; or an explicit build((Object[]) null).","commonSituations":"A helper that resolves an optional argument list and returns null for 'none' instead of an empty array; reflective invocation passing a null args array.","solutions":["Replace a null array with an empty array before calling: build(args == null ? new Object[0] : args).","Return an empty array (not null) from the method that produces the args.","Call build() with no arguments when you have nothing to pass."],"exampleFix":"// before\nObject[] vals = resolveArgs(); // may be null\nURI u = builder.build(vals);\n\n// after\nObject[] vals = resolveArgs();\nURI u = builder.build(vals == null ? new Object[0] : vals);","handlingStrategy":"validation","validationCode":"if (values == null) values = new Object[0];\nURI u = builder.build(values);","typeGuard":"private static Object[] nonNullArgs(Object[] in) {\n    return in == null ? new Object[0] : in;\n}","tryCatchPattern":null,"preventionTips":["Never let an arg-producer return null for the 'empty' case - return an empty array.","Call build() with no arguments when you have no values.","Wrap external arg arrays with a null-coalescing helper."],"tags":["java","keycloak","uri","uri-builder","varargs","null-check"],"backgroundTag":null,"analyzedSha":"66c7e15a3788de7764f07dd2558275a02770e16d","analyzedAt":"2026-08-14T01:36:42.651Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}