{"record":{"id":"c3ec99edd5c33be7","repo":"quarkusio/quarkus","slug":"missing-http-method-in-request-event","errorCode":null,"errorMessage":"Missing HTTP method in request event","messagePattern":"Missing HTTP method in request event","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"extensions/amazon-lambda-http/runtime/src/main/java/io/quarkus/amazon/lambda/http/LambdaHttpHandler.java","lineNumber":191,"sourceCode":"            if (!future.isDone())\n                future.completeExceptionally(new RuntimeException(\"Connection closed\"));\n        }\n    }\n\n    private APIGatewayV2HTTPResponse nettyDispatch(InetSocketAddress clientAddress, APIGatewayV2HTTPEvent request,\n            Context context)\n            throws Exception {\n        QuarkusHttpHeaders quarkusHeaders = new QuarkusHttpHeaders();\n        quarkusHeaders.setContextObject(Context.class, context);\n        quarkusHeaders.setContextObject(APIGatewayV2HTTPEvent.class, request);\n        quarkusHeaders.setContextObject(APIGatewayV2HTTPEvent.RequestContext.class, request.getRequestContext());\n        HttpMethod httpMethod = null;\n        if (request.getRequestContext() != null && request.getRequestContext().getHttp() != null\n                && request.getRequestContext().getHttp().getMethod() != null) {\n            httpMethod = HttpMethod.valueOf(request.getRequestContext().getHttp().getMethod());\n        }\n        if (httpMethod == null) {\n            throw new IllegalStateException(\"Missing HTTP method in request event\");\n        }\n        DefaultHttpRequest nettyRequest = new DefaultHttpRequest(HttpVersion.HTTP_1_1,\n                httpMethod, ofNullable(request.getRawQueryString())\n                        .filter(q -> !q.isEmpty()).map(q -> request.getRawPath() + '?' + q).orElse(request.getRawPath()),\n                quarkusHeaders);\n        if (request.getHeaders() != null) { //apparently this can be null if no headers are sent\n            for (Map.Entry<String, String> header : request.getHeaders().entrySet()) {\n                if (header.getValue() != null) {\n                    // Some header values have commas in them and we don't want to\n                    // split them up into multiple header values.\n                    if (COMMA_HEADERS.contains(header.getKey().toLowerCase(Locale.ROOT))) {\n                        nettyRequest.headers().add(header.getKey(), header.getValue());\n                    } else {\n                        for (String val : header.getValue().split(\",\"))\n                            nettyRequest.headers().add(header.getKey(), val);\n                    }\n                }\n            }","sourceCodeStart":173,"sourceCodeEnd":209,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/amazon-lambda-http/runtime/src/main/java/io/quarkus/amazon/lambda/http/LambdaHttpHandler.java#L173-L209","documentation":"LambdaHttpHandler.nettyDispatch converts the API Gateway V2 HTTP event into a Netty request and requires request.requestContext.http.method. API Gateway v2 always supplies it, so a missing method means the event wasn't a valid HTTP API payload — the handler throws IllegalStateException.","triggerScenarios":"Invoking the Lambda with an event whose requestContext.http.method is null or whose requestContext/http object is absent — e.g. testing with a hand-crafted event, ALB-style payloads, or non-HTTP invocations (direct invoke, other trigger sources).","commonSituations":"Local tests sending minimal/malformed JSON events; routing a custom-resource or scheduled event to an HTTP-mode Lambda; using REST API (v1) payloads with the v2 handler extension; ALB events lacking requestContext.http.","solutions":["Invoke via a real API Gateway HTTP API (v2) so requestContext.http.method is populated","If using ALB or REST API (v1) payloads, use the quarkus-amazon-lambda-rest extension instead of lambda-http","Fix test event JSON to include requestContext.http.method","Verify the trigger type matches the handler (v2 HTTP API events only)"],"exampleFix":"// before\n{\"rawPath\":\"/x\"} // no requestContext\n// after\n{\"rawPath\":\"/x\",\"requestContext\":{\"http\":{\"method\":\"GET\"}}}","handlingStrategy":"validation","validationCode":"if (event.getRequestContext() == null || event.getRequestContext().getHttp() == null\n        || event.getRequestContext().getHttp().getMethod() == null) {\n    throw new IllegalArgumentException(\"Event is not an API Gateway v2 HTTP payload\");\n}","typeGuard":"boolean isV2HttpEvent(APIGatewayV2HTTPEvent e) {\n    return e != null && e.getRequestContext() != null\n        && e.getRequestContext().getHttp() != null\n        && e.getRequestContext().getHttp().getMethod() != null;\n}","tryCatchPattern":"try { handler.handleRequest(event, ctx); } catch (IllegalStateException e) { LOGGER.error(\"Non-HTTP event routed to HTTP Lambda\"); }","preventionTips":["Test with payloads captured from real API Gateway v2","Use quarkus-amazon-lambda-rest for ALB/REST API (v1) events","Validate local test event JSON includes requestContext.http.method"],"tags":["api-gateway","event-payload","amazon-lambda-http"],"backgroundTag":"malformed-event-payload","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}