quarkusio/quarkus · info · RuntimeException
aws context not set
Error message
aws context not set
What it means
GreetingResource.context() injects com.amazonaws.services.lambda.runtime.Context via @Context and throws RuntimeException("aws context not set") when Context.getAwsRequestId() returns null. It verifies the Quarkus Lambda extension makes the AWS Lambda runtime Context available to JAX-RS resources; a null request id means the Context was not populated for the invocation.
Source
Thrown at integration-tests/amazon-lambda-http/src/main/java/io/quarkus/it/amazon/lambda/GreetingResource.java:64
}
byte[] rtn = { 4, 5, 6 };
return rtn;
}
@POST
@Path("empty")
public void empty() {
}
@GET
@Path("context")
@Produces(MediaType.TEXT_PLAIN)
public void context(@Context com.amazonaws.services.lambda.runtime.Context ctx) {
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 ctx) {
if (ctx == null || ctx.getRequestContext().getHttp().getMethod() == null)
throw new RuntimeException();
}
@Inject
APIGatewayV2HTTPEvent event;
@GET
@Path("inject-event")
@Produces(MediaType.TEXT_PLAIN)
public void injectEvent() {
if (event == null)View on GitHub (pinned to e1c734241f)
Solutions
- Invoke the endpoint through API Gateway/Lambda (SNAPSHOT or real deployment) rather than plain dev-mode HTTP so the AWS Context is present
- Check quarkus-amazon-lambda / lambda-http extension version and payload format (v1 vs v2) compatibility
- Verify the test asserts on Context injection; if ctx is null, the earlier null check fires first — ensure the Lambda event source is wired
Example fix
// before // GET /hello/context in quarkus:dev (no Lambda runtime) -> RuntimeException // after aws lambda invoke ... or curl through the API Gateway endpoint so Context.getAwsRequestId() is populated
Defensive patterns
Strategy: validation
Validate before calling
// ensure invocation goes through the Lambda runtime before calling the endpoint
boolean viaLambda = eventSource == EventSource.API_GATEWAY || runningInLambda;
if (!viaLambda) { /* AWS Context will be absent */ } Try / catch
try {
given().get("/hello/context");
} catch (RuntimeException e) {
if ("aws context not set".equals(e.getMessage())) { /* not invoked via Lambda */ }
} Prevention
- Only expect AWS Context injection when invoked through API Gateway/Lambda
- Do not call this endpoint from plain dev-mode HTTP and expect success
- Pin compatible quarkus-amazon-lambda-http extension and payload format versions
When it happens
Trigger: GET /hello/context when the request is not served through the AWS Lambda runtime (e.g. dev-mode plain HTTP without the Lambda event source), or the extension fails to inject the Context so getAwsRequestId() is null.
Common situations: Calling the endpoint locally outside Lambda (no AWS context exists); running behind API Gateway with a payload format misconfiguration; testing that the aws lambda Context propagates and it was not injected.
Related errors
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/96ace16acb159707.
Report an issue: GitHub.