quarkusio/quarkus · error · IllegalArgumentException

name must not be null

Error message

name must not be null

What it means

EntityPart.Builder.builder(name) requires a non-null part name for a multipart part; the name is mandatory per the Jakarta REST EntityPart spec. The EntityPartBuilderImpl constructor validates this immediately and throws IllegalArgumentException when null is passed. Building the part cannot proceed without a name.

Source

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

import org.jboss.resteasy.reactive.common.util.QuarkusMultivaluedHashMap;

public class EntityPartBuilderImpl implements EntityPart.Builder {

    private static final Annotation[] EMPTY_ANNOTATIONS = new Annotation[0];

    private final String name;
    private String fileName;
    private MediaType mediaType;
    private MultivaluedMap<String, String> headers;
    private Serialisers serialisers;

    private Object content;
    private Class<?> contentType;
    private Type contentGenericType;

    public EntityPartBuilderImpl(String name, Serialisers serialisers) {
        if (name == null) {
            throw new IllegalArgumentException("name must not be null");
        }
        this.name = name;
        this.serialisers = serialisers;
        this.mediaType = MediaType.APPLICATION_OCTET_STREAM_TYPE;
        this.headers = new QuarkusMultivaluedHashMap<>();
    }

    @Override
    public EntityPart.Builder mediaType(MediaType mediaType) throws IllegalArgumentException {
        if (mediaType == null) {
            throw new IllegalArgumentException("mediaType must not be null");
        }
        this.mediaType = mediaType;
        return this;
    }

    @Override
    public EntityPart.Builder mediaType(String mediaTypeString) throws IllegalArgumentException {

View on GitHub (pinned to e1c734241f)

Solutions

  1. Pass a literal non-null part name: EntityPart.builder("file").
  2. Check the variable feeding builder(...) for null and fix its initialization.
  3. If the name is dynamic, validate it before building and fail fast with a clear error.
  4. Ensure the field/config key supplying the name is actually populated in the environment.

Example fix

// before
String name = config.get("partName"); // may be null
EntityPart part = EntityPart.builder(name).build();

// after
String name = Objects.requireNonNull(config.get("partName"), "partName");
EntityPart part = EntityPart.builder(name).build();
Defensive patterns

Strategy: validation

Validate before calling

Objects.requireNonNull(partName, "part name must not be null");
EntityPart.Builder b = EntityPart.builder(partName);

Type guard

String requirePartName(String name) {
    return java.util.Objects.requireNonNull(name, "part name must not be null");
}

Try / catch

try {
    EntityPart part = EntityPart.builder(name).build();
} catch (IllegalArgumentException e) {
    throw new IllegalStateException("Multipart part name was null", e);
}

Prevention

When it happens

Trigger: Calling EntityPart.builder(null) or EntityPart.withName(null) — any factory call that passes a null name into the EntityPartBuilderImpl constructor.

Common situations: Programmatically constructing multipart uploads where the part name comes from a variable or config that is null (e.g. missing form field name, uninitialized constant); refactoring that dropped a name literal.

Related errors


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