keycloak/keycloak · error · IllegalArgumentException
values parameter is null
Error message
values parameter is null
What it means
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).
Source
Thrown at common/src/main/java/org/keycloak/common/util/KeycloakUriBuilder.java:661
if (fragment != null) addToPathParamList(params, set, fragment);
return params;
}
private void addToPathParamList(List<String> params, HashSet<String> set, String string) {
Matcher matcher = PathHelper.URI_PARAM_PATTERN.matcher(PathHelper.replaceEnclosedCurlyBraces(string));
while (matcher.find()) {
String param = matcher.group(1);
if (set.contains(param)) continue;
else {
set.add(param);
params.add(param);
}
}
}
public URI build(Object... values) throws IllegalArgumentException {
if (values == null) throw new IllegalArgumentException("values parameter is null");
return buildFromValues(true, false, values);
}
public String buildAsString(Object... values) throws IllegalArgumentException {
if (values == null) throw new IllegalArgumentException("values parameter is null");
return buildFromValuesAsString(true, false, values);
}
protected URI buildFromValues(boolean encodeSlash, boolean encoded, Object... values) {
String buf = buildFromValuesAsString(encodeSlash, encoded, values);
try {
return new URI(buf);
} catch (Exception e) {
throw new RuntimeException("Failed to create URI: " + buf, e);
}
}
protected String buildFromValuesAsString(boolean encodeSlash, boolean encoded, Object... values) {View on GitHub (pinned to 66c7e15a37)
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.
Example fix
// before Object[] vals = resolveArgs(); // may be null URI u = builder.build(vals); // after Object[] vals = resolveArgs(); URI u = builder.build(vals == null ? new Object[0] : vals);
Defensive patterns
Strategy: validation
Validate before calling
if (values == null) values = new Object[0]; URI u = builder.build(values);
Type guard
private static Object[] nonNullArgs(Object[] in) {
return in == null ? new Object[0] : in;
} Prevention
- 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.
When it happens
Trigger: Object[] args = computeArgs(); builder.build(args); where computeArgs() returned null; or an explicit build((Object[]) null).
Common situations: 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.
Related errors
- segments parameter was null
- NULL value for template parameter: {param}
- Failed to create URI: {buf}
- A value was null
- name parameter is null
AI-assisted analysis of keycloak/keycloak@66c7e15a37 (2026-08-14).
Data as JSON: /api/errors/98afb97649e3784b.
Report an issue: GitHub.