quarkusio/quarkus · error · RuntimeException

aws context not set

Error message

aws context not set

What it means

Thrown by the context endpoint when the injected com.amazonaws.services.lambda.runtime.Context is present but getAwsRequestId() returns null. This means the AWS Lambda context was not propagated into the JAX-RS request, so the resource cannot verify it is running behind a Lambda event. It indicates the Lambda REST binding did not supply a usable AWS context object.

Source

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

        }
        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 AwsProxyRequestContext ctx) {
        if (ctx == null)
            throw new RuntimeException();
    }

    @Inject
    AwsProxyRequest event;

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

View on GitHub (pinned to e1c734241f)

Solutions

  1. Deploy/run through the AWS Lambda runtime or SAM local so the Lambda Context is available for injection.
  2. Verify the quarkus-amazon-lambda-rest extension is on the classpath and the function handler is the Quarkus provided one.
  3. Check that aws.lambda.* configuration and the deployment package (zip) produced by the Quarkus Lambda build are used, not a plain JAR runner.

Example fix

// before
mvn package && java -jar target/quarkus-app/quarkus-run.jar // no Lambda context
// after
sam local invoke or deploy target/function.zip built by quarkus:package -Dquarkus.package.type=uber-jar? no -> use the lambda zip
Defensive patterns

Strategy: validation

Validate before calling

if (!isRunningInLambdaEnvironment()) {
    skipContextCheck(); // avoid GET /context outside AWS Lambda/SAM
}

Type guard

boolean hasAwsContext(com.amazonaws.services.lambda.runtime.Context ctx) {
    return ctx != null && ctx.getAwsRequestId() != null;
}

Try / catch

try {
    target("/context").request().get();
} catch (javax.ws.rs.InternalServerErrorException e) {
    log.warn("AWS Lambda context not available in this environment");
}

Prevention

When it happens

Trigger: GET /context when the request is not routed through the AWS Lambda HTTP binding (e.g. running outside Lambda/SAM emulation), or a misconfigured AWS Lambda SOAP/REST integration that injects no Context, leaving an empty/anonymous context with null request id.

Common situations: Testing locally against plain Quarkus instead of the Lambda runtime or SAM local emulation; deploying with the wrong quarkus-amazon-lambda-rest packaging; invoking the function through a path that bypasses the Lambda event bridge.

Related errors


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