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

  1. Use POST or PUT for requests with a multipart body instead of TRACE
  2. Check request.method() before creating the encoder and skip body encoding for TRACE
  3. 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

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


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