aws / aws/aws-lambda-web-adapter
Inconsistent Lambda Context object
- Dominant language
- Rust
- Stars
- 2.7k
- Forks
- 161
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 2
Description
### Summary
The tool supports forwarding the Lambda Context object via the [`x-amzn-lambda-context` header](https://github.com/awslabs/aws-lambda-web-adapter?tab=readme-ov-file#lambda-context). This was [added here](https://github.com/awslabs/aws-lambda-web-adapter/pull/248) and does largely what it says on the tin.
However, given the library is written in Rust, it is using the Rust [typings, objects and functions](https://github.com/awslabs/aws-lambda-web-adapter/blob/main/src/lib.rs#L11) which uses a different casing but also just different names of the [properties](https://docs.aws.amazon.com/lambda/latest/dg/rust-context.html). For example, the Rust library and runtime have the AWS Request ID defined as `request_id`. The Rust runtime (and others) get this from the `lambda-runtime-aws-request-id` header that is passed by the Lambda Service when invoking a new function.
However, all other runtimes then deserialise this in different ways. The Rust object is incompatible with the types from all the other runtimes including: [Node with `awsRequestId`](https://docs.aws.amazon.com/lambda/latest/dg/nodejs-context.html), [.NET with `AwsRequestId`](https://docs.aws.amazon.com/lambda/latest/dg/csharp-context.html) and [Python with `aws_request_id`](https://docs.aws.amazon.com/lambda/latest/dg/python-context.html).
I appreciate this isn't a problem with this extension in particular and more of an inconsistency across all of the runtimes and how they serialise the `Context` object.
### Proposed Solution
It might just be that the documentation in the Readme could be updated to reflect this, particularly with the reference to the Node runtime.
Would this library also consider exposing some types/interfaces that others may use in their code?
### Motivation
I understand this could likely just be 'fixed' with a Readme update, but I wanted to create the issue to discuss if there is anything that could possibly be done to better support strong typing of the Context object by any possible language/framework/runtime that may want to use this in the future. I ended up going down a rabbit hole to see how/where everything was getting set and passed from the Rust lib to my Node application. I had hoped to deserialise the `x-amzn-lambda-context` header to the `Context` object exposed by the [Lambda Types](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/aws-lambda/handler.d.ts#L95)
Contributor guide
Assessment
This issue has not been assessed yet.