quarkusio/quarkus · error · IllegalStateException

Not Allowed

Error message

Not Allowed

What it means

MockBodyHandler is a stub Vert.x BodyHandler used by the AWS Lambda mock event server. It intentionally does not support file uploads, so calling setHandleFileUploads on it always throws IllegalStateException("Not Allowed"). It exists only to satisfy the BodyHandler interface for mock-server routing.

Source

Thrown at extensions/amazon-lambda/event-server/src/main/java/io/quarkus/amazon/lambda/runtime/MockBodyHandler.java:61

        if (!((RoutingContextInternal) context).seenHandler(RoutingContextInternal.BODY_HANDLER)) {
            long contentLength = isPreallocateBodyBuffer ? parseContentLengthHeader(request) : -1;
            BHandler handler = new BHandler(context, contentLength);
            request.handler(handler);
            request.endHandler(v -> handler.end());
            ((RoutingContextInternal) context).visitHandler(RoutingContextInternal.BODY_HANDLER);
        } else {
            // on reroute we need to re-merge the form params if that was desired
            if (mergeFormAttributes && request.isExpectMultipart()) {
                request.params().addAll(request.formAttributes());
            }

            context.next();
        }
    }

    @Override
    public BodyHandler setHandleFileUploads(boolean handleFileUploads) {
        throw new IllegalStateException("Not Allowed");
    }

    @Override
    public BodyHandler setBodyLimit(long bodyLimit) {
        this.bodyLimit = bodyLimit;
        return this;
    }

    @Override
    public BodyHandler setUploadsDirectory(String uploadsDirectory) {
        this.uploadsDir = uploadsDirectory;
        return this;
    }

    @Override
    public BodyHandler setMergeFormAttributes(boolean mergeFormAttributes) {
        this.mergeFormAttributes = mergeFormAttributes;
        return this;

View on GitHub (pinned to e1c734241f)

Solutions

  1. Do not call setHandleFileUploads on MockBodyHandler; it is not supported by design
  2. If file-upload configuration is required, use the standard Vert.x BodyHandler instead of the mock handler
  3. Configure body limits via setBodyLimit, which is supported, instead of file-upload settings
Defensive patterns

Strategy: validation

Validate before calling

if (handler instanceof MockBodyHandler) {
    // skip setHandleFileUploads — unsupported stub
} else {
    handler.setHandleFileUploads(true);
}

Type guard

boolean supportsFileUploadConfig(BodyHandler h) { return !(h instanceof MockBodyHandler); }

Try / catch

try { handler.setHandleFileUploads(false); } catch (IllegalStateException e) { LOGGER.warn("file uploads not configurable on mock handler"); }

Prevention

When it happens

Trigger: Calling setHandleFileUploads(true/false) on the MockBodyHandler instance used by the MockEventServer, typically via Vert.x route configuration code that customizes body handling.

Common situations: Customizing Vert.x routes in tests that reuse the mock event server's handlers; framework code that unconditionally calls setHandleFileUploads on any BodyHandler.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


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