quarkusio/quarkus · error · IllegalArgumentException

Template values null

Error message

Template values null

What it means

UriBuilder.resolveTemplates(Map) throws IllegalArgumentException when the map of template values is null. The method needs a map (possibly empty) to resolve URI template placeholders; null is rejected as an invalid argument.

Source

Thrown at independent-projects/resteasy-reactive/common/runtime/src/main/java/org/jboss/resteasy/reactive/common/jaxrs/UriBuilderImpl.java:1094

    }

    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");

View on GitHub (pinned to e1c734241f)

Solutions

  1. Pass an empty map when there are no values: resolveTemplates(Map.of()) or new HashMap<>()
  2. Initialize the map at the source so callers never see null
  3. Null-guard before the call

Example fix

// before
builder.resolveTemplates(templateValues); // null
// after
builder.resolveTemplates(templateValues == null ? Map.of() : templateValues);
Defensive patterns

Strategy: validation

Validate before calling

Map<String, Object> safe = templateValues == null ? Map.of() : templateValues;
uriBuilder.resolveTemplates(safe);

Type guard

Map<String, Object> nonNull(Map<String, Object> m) {
    return m == null ? Map.of() : m;
}

Try / catch

try {
    return uriBuilder.resolveTemplates(templateValues);
} catch (IllegalArgumentException e) {
    throw new IllegalArgumentException("resolveTemplates rejected: " + e.getMessage(), e);
}

Prevention

When it happens

Trigger: Calling uriBuilder.resolveTemplates(null), or forwarding a Map field/return value that was never initialized.

Common situations: A helper that builds the template-value map lazily and returns null when no values apply; deserialization producing a null map.

Related errors


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/f1f4c661dbcc2b31. Report an issue: GitHub.