quarkusio/quarkus · error · ErrorDataDecoderException

Error decoding multipart field charset (wrapped IOException/

Error message

Error decoding multipart field charset (wrapped IOException/UnsupportedCharsetException)

What it means

Within decodeMultipart, a part's Content-Type may carry a charset attribute; if reading its value or resolving the charset fails (IOException from the Attribute or UnsupportedCharsetException from Charset.forName), the exception is wrapped in an ErrorDataDecoderException.

Source

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

                // content-disposition: form-data; name="pics"; filename="file1.txt"
                // and other immediate values like
                // Content-type: image/gif
                // Content-Type: text/plain
                // Content-Type: text/plain; charset=ISO-8859-1
                // Content-Transfer-Encoding: binary
                // The following line implies a change of mode (mixed mode)
                // Content-type: multipart/mixed, boundary=BbC04y
                return findMultipartDisposition();
            }
            case FIELD: {
                // Now get value according to Content-Type and Charset
                Charset localCharset = null;
                Attribute charsetAttribute = currentFieldAttributes.get(HttpHeaderValues.CHARSET);
                if (charsetAttribute != null) {
                    try {
                        localCharset = Charset.forName(charsetAttribute.getValue());
                    } catch (IOException | UnsupportedCharsetException e) {
                        throw new ErrorDataDecoderException(e);
                    }
                }
                Attribute nameAttribute = currentFieldAttributes.get(HttpHeaderValues.NAME);
                if (currentAttribute == null) {
                    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 {
                        if (size > 0) {
                            currentAttribute = factory.createAttribute(response,

View on GitHub (pinned to e1c734241f)

Solutions

  1. Fix the server to emit a standard supported charset name (e.g. UTF-8)
  2. Verify the charset is supported on the running JVM (Charset.isSupported(name))
  3. Strip the charset parameter from the part so the decoder's default charset is used
  4. Catch ErrorDataDecoderException and decode the raw bytes manually

Example fix

// before (server part header)
Content-Type: text/plain; charset=UTF_8
// after
Content-Type: text/plain; charset=UTF-8
Defensive patterns

Strategy: validation

Validate before calling

String cs = partContentTypeCharset; // parsed from part header
if (cs != null && !Charset.isSupported(cs)) {
    log.warn("Unsupported charset " + cs + ", using default");
}

Try / catch

try { decoder.offer(chunk); } catch (ErrorDataDecoderException e) { if (e.getCause() instanceof UnsupportedCharsetException) { /* decode raw bytes with UTF-8 */ } }

Prevention

When it happens

Trigger: A multipart part declares 'Content-Type: text/plain; charset=<name>' where the name is an unsupported/unknown charset (e.g. charset=Cp1257 on a JVM lacking that charset, or a typo like charset=UTF_8), and getAttribute().getValue() throws IOException.

Common situations: Servers emitting non-standard charset names; JVM with a restricted charset provider; corrupted part headers.

Related errors


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