quarkusio/quarkus · error · IllegalArgumentException
map key null
Error message
map key null
What it means
UriBuilder.resolveTemplates(Map) throws IllegalArgumentException when the map contains a null key. Template variable names are the map keys, and a null key cannot correspond to any {placeholder} in the template, so it is rejected before resolution.
Source
Thrown at independent-projects/resteasy-reactive/common/runtime/src/main/java/org/jboss/resteasy/reactive/common/jaxrs/UriBuilderImpl.java:1096
public String toTemplate() {
return buildString(new HashMap<String, Object>(), true, true, true);
}
public UriBuilder resolveTemplate(String name, Object value) throws IllegalArgumentException {
if (name == null)
throw new IllegalArgumentException("Name is null");
if (value == null)
throw new IllegalArgumentException("Value is null");
HashMap<String, Object> vals = new HashMap<String, Object>();
vals.put(name, value);
return resolveTemplates(vals);
}
public UriBuilder resolveTemplates(Map<String, Object> templateValues) throws IllegalArgumentException {
if (templateValues == null)
throw new IllegalArgumentException("Template values null");
if (templateValues.containsKey(null))
throw new IllegalArgumentException("map key null");
return uriTemplate(buildCharSequence(templateValues, false, true, true));
}
public UriBuilder resolveTemplate(String name, Object value, boolean encodeSlashInPath) throws IllegalArgumentException {
if (name == null)
throw new IllegalArgumentException("Name is null");
if (value == null)
throw new IllegalArgumentException("Value is null");
HashMap<String, Object> vals = new HashMap<String, Object>();
vals.put(name, value);
return uriTemplate(buildCharSequence(vals, false, true, encodeSlashInPath));
}
public UriBuilder resolveTemplateFromEncoded(String name, Object value) throws IllegalArgumentException {
if (name == null)
throw new IllegalArgumentException("Name is null");
if (value == null)
throw new IllegalArgumentException("Value is null");View on GitHub (pinned to e1c734241f)
Solutions
- Filter out null keys before calling: templateValues.keySet().removeIf(Objects::isNull) on a mutable copy
- Fix the producer of the map so keys are always non-null
- Validate keys when populating the map and throw a contextual error early
Example fix
// before builder.resolveTemplates(params); // params.containsKey(null) // after Map<String, Object> safe = new HashMap<>(params); safe.keySet().removeIf(Objects::isNull); builder.resolveTemplates(safe);
Defensive patterns
Strategy: validation
Validate before calling
for (String key : templateValues.keySet()) {
if (key == null) {
throw new IllegalArgumentException("template value map has a null key");
}
}
uriBuilder.resolveTemplates(templateValues); Type guard
boolean hasNoNullKeys(Map<String, Object> m) {
return m != null && !m.containsKey(null);
} Try / catch
try {
return uriBuilder.resolveTemplates(templateValues);
} catch (IllegalArgumentException e) {
Map<String, Object> cleaned = new HashMap<>(templateValues);
cleaned.keySet().removeIf(Objects::isNull);
return uriBuilder.resolveTemplates(cleaned);
} Prevention
- Reject null keys when populating parameter maps
- Use TreeMap or Map.of() (both reject null keys) for template maps
- Sanitize merged maps before passing them on
When it happens
Trigger: Passing a HashMap that a caller populated with a null key (HashMap permits null keys), e.g. map.put(null, value) — often from merging maps or reading keyed data where a key is missing.
Common situations: Merging several parameter maps where one is keyed by a nullable name; building the map from data where the 'name' column/field is null.
Related errors
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/5a7bb51060761ee6.
Report an issue: GitHub.