quarkusio/quarkus · error · ErrorDataDecoderException

Error decoding multipart charset (wrapped IOException/Unsupp

Error message

Error decoding multipart charset (wrapped IOException/UnsupportedCharsetException)

What it means

This ErrorDataDecoderException wraps IOException or UnsupportedCharsetException raised while resolving the charset attribute for a multipart file upload. Charset.forName either could not read the attribute value (IOException) or the charset name is not supported by the JVM (UnsupportedCharsetException), aborting the decode. It indicates an invalid or unreadable charset parameter on the part.

Source

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

            }
            if (code.equals(TransferEncodingMechanism.BIT7.value())) {
                localCharset = CharsetUtil.US_ASCII;
            } else if (code.equals(TransferEncodingMechanism.BIT8.value())) {
                localCharset = CharsetUtil.ISO_8859_1;
                mechanism = TransferEncodingMechanism.BIT8;
            } else if (code.equals(TransferEncodingMechanism.BINARY.value())) {
                // no real charset, so let the default
                mechanism = TransferEncodingMechanism.BINARY;
            } else {
                throw new ErrorDataDecoderException("TransferEncoding Unknown: " + code);
            }
        }
        Attribute charsetAttribute = currentFieldAttributes.get(HttpHeaderValues.CHARSET);
        if (charsetAttribute != null) {
            try {
                localCharset = Charset.forName(charsetAttribute.getValue());
            } catch (IOException | UnsupportedCharsetException e) {
                throw new ErrorDataDecoderException(e);
            }
        }
        if (currentFileUpload == null) {
            Attribute filenameAttribute = currentFieldAttributes.get(HttpHeaderValues.FILENAME);
            Attribute nameAttribute = currentFieldAttributes.get(HttpHeaderValues.NAME);
            Attribute contentTypeAttribute = currentFieldAttributes.get(HttpHeaderNames.CONTENT_TYPE);
            Attribute lengthAttribute = currentFieldAttributes.get(HttpHeaderNames.CONTENT_LENGTH);
            long size;
            try {
                size = lengthAttribute != null ? Long.parseLong(lengthAttribute.getValue()) : 0L;
            } catch (IOException e) {
                throw new ErrorDataDecoderException(e);
            } catch (NumberFormatException ignored) {
                size = 0;
            }
            try {
                String contentType;
                if (contentTypeAttribute != null) {

View on GitHub (pinned to e1c734241f)

Solutions

  1. Send a standard charset name such as UTF-8 or ISO-8859-1 in the part's charset parameter, or omit charset entirely.
  2. Log the raw charset value and correct the server-side header generation.
  3. Verify the JVM supports the charset (Charset.isSupported(name)) and use a full JVM profile if needed.
  4. Rule out attribute storage I/O problems by checking temp-dir health when the wrapped cause is IOException.

Example fix

// before
Content-Disposition: form-data; name="f"; filename="a.txt"; charset=ansi_x3.4-1968
// after
Content-Disposition: form-data; name="f"; filename="a.txt"; charset=UTF-8
Defensive patterns

Strategy: validation

Validate before calling

// Check charset support before emitting the part
String cs = params.get("charset");
if (cs != null && !Charset.isSupported(cs.trim().replace("\"", ""))) {
    throw new IllegalStateException("Unsupported charset label in multipart part: " + cs);
}

Type guard

static boolean hasSupportedCharset(Attribute charsetAttribute) throws IOException {
    return charsetAttribute == null
        || Charset.isSupported(charsetAttribute.getValue().trim());
}

Try / catch

try {
    upload = decoder.getFileUpload(encoding);
} catch (ErrorDataDecoderException e) {
    if (e.getCause() instanceof UnsupportedCharsetException) {
        throw new BadRequestException("Part declares a charset unknown to this JVM: " + e.getCause().getMessage(), e);
    }
    throw e;
}

Prevention

When it happens

Trigger: A part declares a charset parameter whose value (via charsetAttribute.getValue()) is unreadable (IOException) or names a charset unavailable on the JVM, e.g. a platform-specific label like 'ANSI_X3.4-1968' on a restricted JVM.

Common situations: Servers sending non-standard charset labels; minimal JVM distributions (e.g. compact profiles) lacking extended charsets; corrupted attribute storage causing IO failures.

Related errors


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