quarkusio/quarkus · info · RuntimeException

aws context not set

Error message

aws context not set

What it means

In the RESTEasy Reactive variant, GreetingResource reads the AWS Lambda Context via a field (com.amazonaws.services.lambda.runtime.Context ctx injected by the Quarkus Lambda extension, line 47-48) and throws RuntimeException("aws context not set") when ctx.getAwsRequestId() is null. It verifies Context injection into resources in the reactive stack; null means the Lambda runtime Context was not populated.

Source

Thrown at integration-tests/amazon-lambda-http-resteasy-reactive/src/main/java/io/quarkus/it/amazon/lambda/GreetingResource.java:57

    }

    @POST
    @Path("empty")
    public void empty() {

    }

    @Context
    com.amazonaws.services.lambda.runtime.Context ctx;

    @GET
    @Path("context")
    @Produces(MediaType.TEXT_PLAIN)
    public void context() {
        if (ctx == null)
            throw new RuntimeException();
        if (ctx.getAwsRequestId() == null)
            throw new RuntimeException("aws context not set");
    }

    @GET
    @Path("proxyRequestContext")
    @Produces(MediaType.TEXT_PLAIN)
    public void proxyRequestContext(@Context APIGatewayV2HTTPEvent event) {
        if (event == null)
            throw new RuntimeException();
    }

    @Inject
    APIGatewayV2HTTPEvent injectEvent;

    @GET
    @Path("inject-event")
    @Produces(MediaType.TEXT_PLAIN)
    public void injectEvent() {
        if (injectEvent == null)

View on GitHub (pinned to e1c734241f)

Solutions

  1. Hit the endpoint via API Gateway/Lambda so the AWS runtime Context exists during the invocation
  2. Confirm the quarkus-amazon-lambda-http (reactive) extension version supports Context field injection and matching payload format
  3. If testing locally, expect the failure — the AWS Context is only present during real Lambda invocations

Example fix

// before
// GET /hello/context in local dev mode -> ctx == null / requestId null
// after
// deploy or test through SAM/API Gateway so Context is injected:
curl https://<api-gateway-id>.execute-api.<region>.amazonaws.com/hello/context
Defensive patterns

Strategy: validation

Validate before calling

// only meaningful when invoked via Lambda
boolean viaLambda = eventSource == EventSource.API_GATEWAY || runningInLambda;
if (!viaLambda) { /* injected AWS Context will be null */ }

Try / catch

try {
    given().get("/hello/context");
} catch (RuntimeException e) {
    if ("aws context not set".equals(e.getMessage())) { /* no Lambda runtime context */ }
}

Prevention

When it happens

Trigger: GET /hello/context when served outside the AWS Lambda invocation path (plain dev-mode HTTP), or when the Lambda extension fails to populate the injected Context so getAwsRequestId() is null.

Common situations: Local quarkus:dev testing where no AWS Context exists; payload format (v1/v2) mismatch preventing Context injection; extension wiring issues in the reactive variant.

Related errors


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