{"record":{"id":"96ace16acb159707","repo":"quarkusio/quarkus","slug":"aws-context-not-set","errorCode":null,"errorMessage":"aws context not set","messagePattern":"aws context not set","errorType":"http","errorClass":"RuntimeException","httpStatus":500,"severity":"info","filePath":"integration-tests/amazon-lambda-http/src/main/java/io/quarkus/it/amazon/lambda/GreetingResource.java","lineNumber":64,"sourceCode":"        }\n        byte[] rtn = { 4, 5, 6 };\n        return rtn;\n    }\n\n    @POST\n    @Path(\"empty\")\n    public void empty() {\n\n    }\n\n    @GET\n    @Path(\"context\")\n    @Produces(MediaType.TEXT_PLAIN)\n    public void context(@Context com.amazonaws.services.lambda.runtime.Context ctx) {\n        if (ctx == null)\n            throw new RuntimeException();\n        if (ctx.getAwsRequestId() == null)\n            throw new RuntimeException(\"aws context not set\");\n    }\n\n    @GET\n    @Path(\"proxyRequestContext\")\n    @Produces(MediaType.TEXT_PLAIN)\n    public void proxyRequestContext(@Context APIGatewayV2HTTPEvent ctx) {\n        if (ctx == null || ctx.getRequestContext().getHttp().getMethod() == null)\n            throw new RuntimeException();\n    }\n\n    @Inject\n    APIGatewayV2HTTPEvent event;\n\n    @GET\n    @Path(\"inject-event\")\n    @Produces(MediaType.TEXT_PLAIN)\n    public void injectEvent() {\n        if (event == null)","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/integration-tests/amazon-lambda-http/src/main/java/io/quarkus/it/amazon/lambda/GreetingResource.java#L46-L82","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\n// GET /hello/context in quarkus:dev (no Lambda runtime) -> RuntimeException\n// after\naws lambda invoke ... or curl through the API Gateway endpoint so Context.getAwsRequestId() is populated","handlingStrategy":"validation","validationCode":"// ensure invocation goes through the Lambda runtime before calling the endpoint\nboolean viaLambda = eventSource == EventSource.API_GATEWAY || runningInLambda;\nif (!viaLambda) { /* AWS Context will be absent */ }","typeGuard":null,"tryCatchPattern":"try {\n    given().get(\"/hello/context\");\n} catch (RuntimeException e) {\n    if (\"aws context not set\".equals(e.getMessage())) { /* not invoked via Lambda */ }\n}","preventionTips":["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"],"tags":["aws-lambda","context-injection","test","api-gateway"],"backgroundTag":"missing-runtime-context","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"}