quarkusio/quarkus · error · IllegalArgumentException

Values is null

Error message

Values is null

What it means

UriBuilder.buildFromEncoded(Object...) throws IllegalArgumentException when the values array itself is null. This method substitutes template variables with pre-encoded values, and a null varargs array cannot be meaningfully processed, so the implementation rejects it up front.

Source

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

    public String getFragment() {
        return fragment;
    }

    public UriBuilder segment(String... segments) throws IllegalArgumentException {
        if (segments == null)
            throw new IllegalArgumentException("Segment parameter is null");
        for (String segment : segments) {
            if (segment == null)
                throw new IllegalArgumentException("Segment is null");
            path(Encode.encodePathSegment(segment));
        }
        return this;
    }

    public URI buildFromEncoded(Object... values) throws IllegalArgumentException, UriBuilderException {
        if (values == null)
            throw new IllegalArgumentException("Values is null");
        return buildFromValues(false, true, values);
    }

    public UriBuilder replacePath(String path) {
        if (path == null) {
            this.path = null;
            return this;
        }
        this.path = Encode.encodePath(path);
        return this;
    }

    public URI build(Object[] values, boolean encodeSlashInPath) throws IllegalArgumentException, UriBuilderException {
        if (values == null)
            throw new IllegalArgumentException("Values is null");
        return buildFromValues(encodeSlashInPath, false, values);
    }

View on GitHub (pinned to e1c734241f)

Solutions

  1. Pass an empty array instead of null: buildFromEncoded(new Object[0])
  2. Ensure the calling helper returns Object[]... / an empty array rather than null
  3. Guard the call site: if (values != null) builder.buildFromEncoded(values) else builder.build()

Example fix

// before
URI uri = builder.buildFromEncoded(args); // args == null -> IllegalArgumentException
// after
URI uri = builder.buildFromEncoded(args == null ? new Object[0] : args);
Defensive patterns

Strategy: validation

Validate before calling

Object[] safeValues = values == null ? new Object[0] : values;
URI uri = uriBuilder.buildFromEncoded(safeValues);

Type guard

boolean isUsableValues(Object[] values) {
    return values != null;
}

Try / catch

try {
    return uriBuilder.buildFromEncoded(values);
} catch (IllegalArgumentException e) {
    log.warn("buildFromEncoded rejected: " + e.getMessage());
    return uriBuilder.build();
}

Prevention

When it happens

Trigger: Calling uriBuilder.buildFromEncoded(null) directly, or forwarding a null values array obtained from another call site (e.g. a helper that collects template arguments and returns null when there are none).

Common situations: Generic URI-building helper methods that pass through a values array which is null on some code path; refactoring where a previously empty array became null.

Related errors


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