quarkusio/quarkus · error · ErrorDataDecoderException

Error decoding content-disposition attribute (wrapped NullPo

Error message

Error decoding content-disposition attribute (wrapped NullPointerException/IllegalArgumentException)

What it means

While parsing the Content-Disposition header of a multipart part, each extra parameter (after the first two tokens) is converted via getContentDispositionAttribute; a NullPointerException or IllegalArgumentException there (missing '=', empty/invalid parameter, missing name) is wrapped into ErrorDataDecoderException.

Source

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

            }
            String[] contents = splitMultipartHeader(newline);
            if (HttpHeaderNames.CONTENT_DISPOSITION.contentEqualsIgnoreCase(contents[0])) {
                boolean checkSecondArg;
                if (currentStatus == MultiPartStatus.DISPOSITION) {
                    checkSecondArg = HttpHeaderValues.FORM_DATA.contentEqualsIgnoreCase(contents[1]);
                } else {
                    checkSecondArg = HttpHeaderValues.ATTACHMENT.contentEqualsIgnoreCase(contents[1])
                            || HttpHeaderValues.FILE.contentEqualsIgnoreCase(contents[1]);
                }
                if (checkSecondArg) {
                    // read next values and store them in the map as Attribute
                    for (int i = 2; i < contents.length; i++) {
                        String[] values = contents[i].split("=", 2);
                        Attribute attribute;
                        try {
                            attribute = getContentDispositionAttribute(values);
                        } catch (NullPointerException | IllegalArgumentException e) {
                            throw new ErrorDataDecoderException(e);
                        }
                        currentFieldAttributes.put(attribute.getName(), attribute);
                    }
                }
            } else if (HttpHeaderNames.CONTENT_TRANSFER_ENCODING.contentEqualsIgnoreCase(contents[0])) {
                Attribute attribute;
                try {
                    attribute = factory.createAttribute(response, HttpHeaderNames.CONTENT_TRANSFER_ENCODING.toString(),
                            cleanString(contents[1]));
                } catch (NullPointerException | IllegalArgumentException e) {
                    throw new ErrorDataDecoderException(e);
                }

                currentFieldAttributes.put(HttpHeaderNames.CONTENT_TRANSFER_ENCODING, attribute);
            } else if (HttpHeaderNames.CONTENT_LENGTH.contentEqualsIgnoreCase(contents[0])) {
                Attribute attribute;
                try {
                    attribute = factory.createAttribute(response, HttpHeaderNames.CONTENT_LENGTH.toString(),

View on GitHub (pinned to e1c734241f)

Solutions

  1. Fix the sender to emit RFC-compliant Content-Disposition parameters, each as key=value
  2. Remove or repair malformed parameters (e.g. bare 'name' without '=value')
  3. If a non-ASCII filename is the culprit, encode it in a form the parser accepts (quoted ASCII)
  4. Catch ErrorDataDecoderException and inspect the wrapped NPE/IAE cause to pinpoint the bad parameter

Example fix

// before (part header)
Content-Disposition: form-data; name; filename=
// after
Content-Disposition: form-data; name="file1"; filename="report.txt"
Defensive patterns

Strategy: validation

Validate before calling

for (String p : disposition.split(";")) {
    p = p.trim();
    if (!p.isEmpty() && !p.equals("form-data") && !p.contains("=")) {
        throw new IllegalArgumentException("Malformed disposition param: " + p);
    }
}

Try / catch

try { decoder.offer(chunk); } catch (ErrorDataDecoderException e) { if (e.getCause() instanceof IllegalArgumentException) { log.error("Bad Content-Disposition parameter", e); } }

Prevention

When it happens

Trigger: A Content-Disposition header with malformed extra parameters, e.g. 'form-data; name' (no '='), 'form-data; =value', or a filename/name parameter that the strict parser rejects.

Common situations: Non-conformant servers emitting odd disposition parameters (e.g. 'filename*=' RFC 5987 variants the parser doesn't handle); proxies altering the header; hand-crafted responses in tests.

Related errors


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