quarkusio/quarkus · error · NullPointerException

Multipart field name cannot be null

Error message

Multipart field name cannot be null

What it means

This constructor of QuarkusMultipartFormDataPart validates its arguments and throws NullPointerException when the multipart field name is null. The name is required to build the part's Content-Disposition header, so a null name would produce an invalid multipart body. The library fails fast at construction time rather than producing a malformed request.

Source

Thrown at independent-projects/resteasy-reactive/client/runtime/src/main/java/org/jboss/resteasy/reactive/client/impl/multipart/QuarkusMultipartFormDataPart.java:35

    private final boolean isObject;
    private final Class<?> type;
    private final Buffer content;
    private final Multi<Byte> multiByteContent;

    public QuarkusMultipartFormDataPart(String name, Buffer content, String mediaType, Class<?> type) {
        this(name, null, content, mediaType, type);
    }

    public QuarkusMultipartFormDataPart(String name, String filename, Buffer content, String mediaType, Class<?> type) {
        this.name = name;
        this.filename = filename;
        this.content = content;
        this.mediaType = mediaType;
        this.type = type;
        this.multiByteContent = null;

        if (name == null) {
            throw new NullPointerException("Multipart field name cannot be null");
        }
        if (mediaType == null) {
            throw new NullPointerException("Multipart field media type cannot be null");
        }
        if (type == null) {
            throw new NullPointerException("Multipart field media type cannot be null");
        }
        this.isObject = true;
        this.value = null;
        this.pathname = null;
        this.text = false;
    }

    public QuarkusMultipartFormDataPart(String name, String filename, Multi<Byte> content, String mediaType, boolean text) {
        if (name == null) {
            throw new NullPointerException("Multipart field name cannot be null");
        }
        if (mediaType == null) {

View on GitHub (pinned to e1c734241f)

Solutions

  1. Pass a non-null field name when constructing the part
  2. For REST Client interfaces, ensure each @Part method parameter has a name (parameter name retention or explicit @Part(value=...))
  3. Validate the name source before constructing the part

Example fix

// before
new QuarkusMultipartFormDataPart(name, value, mediaType, type); // name == null
// after
Objects.requireNonNull(name, "name");
new QuarkusMultipartFormDataPart(name, value, mediaType, type);
Defensive patterns

Strategy: validation

Validate before calling

if (name == null) throw new IllegalArgumentException("Multipart field name must not be null");

Type guard

boolean hasName(String name) { return name != null && !name.isBlank(); }

Try / catch

try {
    return new QuarkusMultipartFormDataPart(name, value, mediaType, type);
} catch (NullPointerException e) {
    throw new IllegalArgumentException("Multipart part name is required: " + e.getMessage(), e);
}

Prevention

When it happens

Trigger: Calling new QuarkusMultipartFormDataPart(null, objectValue, mediaType, type) — the object-valued constructor — with a null field name, typically when the name comes from an uninitialized variable, a missing annotation attribute, or a reflection-derived value.

Common situations: REST Client multipart @Part handling where the field name is computed at runtime and resolves to null; dynamic part building from a map with null keys; refactoring that removed a hardcoded name.

Related errors


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