quarkusio/quarkus · error · ErrorDataDecoderException

TransferEncoding Unknown: " + code

Error message

TransferEncoding Unknown: " + code

What it means

The decoder only supports 7bit, 8bit, and binary Content-Transfer-Encoding values for file uploads. Any other value (e.g. base64, quoted-printable) triggers ErrorDataDecoderException 'TransferEncoding Unknown'. Quarkus' multipart response decoder does not transcode content, so unsupported encodings are rejected outright.

Source

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

        // Default
        TransferEncodingMechanism mechanism = TransferEncodingMechanism.BIT7;
        if (encoding != null) {
            String code;
            try {
                code = encoding.getValue().toLowerCase();
            } catch (IOException e) {
                throw new ErrorDataDecoderException(e);
            }
            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;

View on GitHub (pinned to e1c734241f)

Solutions

  1. Change the server to send parts with Content-Transfer-Encoding: binary (or omit the header, defaulting to 7bit) and send raw bytes.
  2. If the server must send base64, decode the body yourself instead of relying on this decoder.
  3. Remove base64/quoted-printable transformation from the server's multipart writer.
  4. Use plain multipart/form-data with raw octet streams, which is the norm over HTTP.

Example fix

// before
Content-Transfer-Encoding: base64
// after
Content-Transfer-Encoding: binary
Defensive patterns

Strategy: validation

Validate before calling

// Only allow supported transfer encodings in emitted parts
Set<String> OK = Set.of("7bit", "8bit", "binary");
if (cte != null && !OK.contains(cte.toLowerCase())) {
    throw new IllegalStateException("Unsupported Content-Transfer-Encoding for HTTP multipart: " + cte);
}

Type guard

static boolean isSupportedTransferEncoding(String cte) {
    return cte == null || Set.of("7bit", "8bit", "binary").contains(cte.toLowerCase());
}

Try / catch

try {
    result = decodeMultipart(...);
} catch (ErrorDataDecoderException e) {
    if (String.valueOf(e.getMessage()).startsWith("TransferEncoding Unknown")) {
        throw new UnsupportedEncodingException("Server used base64/quoted-printable; request raw binary parts", e);
    }
    throw e;
}

Prevention

When it happens

Trigger: A file-upload part declares Content-Transfer-Encoding with a value other than '7bit', '8bit', or 'binary' (after lowercasing), such as 'base64' or 'quoted-printable'.

Common situations: Servers that MIME-encode parts (base64) like email attachments; proxies adding transfer encodings; misconfigured exporters that copy SMTP-style headers into HTTP multipart.

Related errors


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