quarkusio/quarkus · error · ErrorDataDecoderException
Illegal charset in multipart response Content-Type (wrapped)
Error message
Illegal charset in multipart response Content-Type (wrapped)
What it means
When the Content-Type header of a multipart response declares a charset parameter whose name is not a legal charset name, Charset.forName throws IllegalCharsetNameException, which is wrapped into an ErrorDataDecoderException. This indicates a malformed charset= parameter in the response's Content-Type header.
Source
Thrown at independent-projects/resteasy-reactive/client/runtime/src/main/java/org/jboss/resteasy/reactive/client/impl/multipart/QuarkusMultipartResponseDecoder.java:227
Charset charset) {
this.response = checkNotNull(response, "request");
this.charset = checkNotNull(charset, "charset");
this.factory = checkNotNull(factory, "factory");
// Fill default values
String contentTypeValue = this.response.headers().get(HttpHeaderNames.CONTENT_TYPE);
if (contentTypeValue == null) {
throw new ErrorDataDecoderException("No '" + HttpHeaderNames.CONTENT_TYPE + "' header present.");
}
String[] dataBoundary = getMultipartDataBoundary(contentTypeValue);
if (dataBoundary != null) {
multipartDataBoundary = dataBoundary[0];
if (dataBoundary.length > 1 && dataBoundary[1] != null) {
try {
this.charset = Charset.forName(dataBoundary[1]);
} catch (IllegalCharsetNameException e) {
throw new ErrorDataDecoderException(e);
}
}
} else {
destroy();
throw new ErrorDataDecoderException("Unable to parse multipart response - No delimiter specified");
}
currentStatus = MultiPartStatus.HEADERDELIMITER;
try {
if (this.response instanceof HttpContent) {
// Offer automatically if the given request is als type of HttpContent
// See #1089
offer((HttpContent) this.response);
} else {
parseBody();
}
} catch (Throwable e) {
destroy();View on GitHub (pinned to e1c734241f)
Solutions
- Fix the server to emit a valid charset name such as UTF-8
- Log the raw Content-Type header to identify the malformed value
- Catch ErrorDataDecoderException and re-try decoding with a forced default charset if the library API allows
- Reject or sanitize the response at the proxy/gateway layer
Example fix
// before (server) Content-Type: multipart/mixed; boundary=xyz; charset=utf 8 // after Content-Type: multipart/mixed; boundary=xyz; charset=UTF-8
Defensive patterns
Strategy: validation
Validate before calling
String ct = response.headers().get(HttpHeaderNames.CONTENT_TYPE);
for (String p : ct.split(";")) {
p = p.trim();
if (p.startsWith("charset=")) {
String name = p.substring(8).replace("\"", "");
if (!Charset.isSupported(name)) throw new IllegalArgumentException("Illegal charset: " + name);
}
} Try / catch
try { new QuarkusMultipartResponseDecoder(response, factory, charset); } catch (ErrorDataDecoderException e) { log.error("Bad charset in Content-Type", e.getCause()); } Prevention
- Sanitize charset parameters at the gateway
- Only accept charset values passing Charset.isSupported/isValid name check
When it happens
Trigger: Response Content-Type like multipart/mixed; boundary=...; charset=<invalid name> where the charset name contains characters that are not legal charset-name syntax (e.g. spaces, '*', '=') — not merely an unknown charset.
Common situations: Server frameworks or custom code emitting a malformed charset parameter (e.g. charset=UTF_8 or charset="utf 8"); proxies rewriting Content-Type incorrectly.
Related errors
- Error decoding multipart field charset (wrapped IOException/
- Cannot create a Encoder if request is a TRACE
- Needs a boundary value
- No 'Content-Type' header present.
- Unable to parse multipart response - No delimiter specified
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/a958f73f0c3893d9.
Report an issue: GitHub.