quarkusio/quarkus · error · ErrorDataEncoderException
Cannot create a Encoder if request is a TRACE
Error message
Cannot create a Encoder if request is a TRACE
What it means
PausableHttpPostRequestEncoder refuses construction when the target request uses the HTTP TRACE method, because TRACE requests must not carry a body. It throws ErrorDataEncoderException in the constructor.
Source
Thrown at independent-projects/resteasy-reactive/client/runtime/src/main/java/org/jboss/resteasy/reactive/client/impl/multipart/PausableHttpPostRequestEncoder.java:278
* True if the FORM is a ENCTYPE="multipart/form-data"
* @param charset
* the charset to use as default
* @param encoderMode
* the mode for the encoder to use. See {@link EncoderMode} for the details.
* @throws NullPointerException
* for request or charset or factory
* @throws ErrorDataEncoderException
* if the request is a TRACE
*/
public PausableHttpPostRequestEncoder(
HttpDataFactory factory, HttpRequest request, boolean multipart, int maxChunkSize,
Charset charset, EncoderMode encoderMode)
throws ErrorDataEncoderException {
this.request = checkNotNull(request, "request");
this.charset = checkNotNull(charset, "charset");
this.factory = checkNotNull(factory, "factory");
if (HttpMethod.TRACE.equals(request.method())) {
throw new ErrorDataEncoderException("Cannot create a Encoder if request is a TRACE");
}
// Fill default values
bodyListDatas = new ArrayList<>();
// default mode
isLastChunk = false;
isLastChunkSent = false;
isMultipart = multipart;
this.maxChunkSize = maxChunkSize;
multipartHttpDatas = new ArrayList<>();
this.encoderMode = encoderMode;
if (isMultipart) {
initDataMultipart();
}
}
/**
* Clean all HttpDatas (on Disk) for the current request.
*/View on GitHub (pinned to e1c734241f)
Solutions
- Use POST or PUT for requests with a multipart body instead of TRACE
- Check request.method() before creating the encoder and skip body encoding for TRACE
- Refactor shared request-building code to select method-specific encoding paths
Example fix
// before
encoder = new PausableHttpPostRequestEncoder(request, true, charset, factory, mode);
// after
if (!HttpMethod.TRACE.equals(request.method())) {
encoder = new PausableHttpPostRequestEncoder(request, true, charset, factory, mode);
} Defensive patterns
Strategy: validation
Validate before calling
if (HttpMethod.TRACE.equals(request.method())) { throw new IllegalArgumentException("TRACE must not carry a body"); } Type guard
null
Try / catch
try { encoder = new PausableHttpPostRequestEncoder(request, true, cs, f, mode); } catch (ErrorDataEncoderException e) { /* fall back to bodyless request */ } Prevention
- Only attach multipart bodies to POST/PUT requests
- Validate the HTTP method at the request-builder layer
- Keep default-method configuration separate from body-encoding paths
When it happens
Trigger: new PausableHttpPostRequestEncoder(HttpRequest with method TRACE, isMultipart, charset, factory, encoderMode).
Common situations: Configuring a client request factory with a wrong default method; generic request-building code that attaches a multipart body without checking the verb.
Related errors
- Unsupported HTTP method '<method>' for @RequestMapping. Offe
- setting content of MultiByteHttpData is not supported
- adding content to MultiByteHttpData is not supported
- getting all the contents of a MultiByteHttpData is not suppo
- MultiByteHttpData invoked on an invalid context :
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/4cb739949d0417bf.
Report an issue: GitHub.