Skip to content

fix: Local Server should pass HTTP headers down to the Lambda Runtime#643

Open
manojmahapatra wants to merge 3 commits intoawslabs:mainfrom
manojmahapatra:fix/local-server-forward-headers
Open

fix: Local Server should pass HTTP headers down to the Lambda Runtime#643
manojmahapatra wants to merge 3 commits intoawslabs:mainfrom
manojmahapatra:fix/local-server-forward-headers

Conversation

@manojmahapatra
Copy link

Issue #

#607

Description of changes

The local HTTP server was not forwarding user‑provided headers to the runtime’s response. It passes all headers through to the runtime. This it makes local behavior match the Lambda runtime API contract and allows developers to opt into metadata by sending the appropriate runtime headers.

New/existing dependencies impact assessment, if applicable

N/A

Conventional Commits

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@sebsto sebsto added the 🔨 semver/patch No public API change. label Feb 17, 2026
@sebsto sebsto self-assigned this Feb 17, 2026
@sebsto
Copy link
Collaborator

sebsto commented Feb 17, 2026

Thank you @manojmahapatra, this is a really good first contribution. I added a tiny suggestion in the code.

May I suggest to also update the Examples/MultiTenant

1/ add an example that doesn't depend on the API Gateway.
2/ update the README file and add a section about Local testing?
We need to show user it's actually possible to make an invocation like this

(the APIGateway case is already covered, users can list the forwarded headers in the payload)

  # Test multi-tenant function locally
  curl -X POST http://127.0.0.1:7000/invoke \
    -H "Content-Type: application/json" \
    -H "Lambda-Runtime-Aws-Tenant-Id: tenant-123" \
    -d '{"message" :  "hello"}'


logger.trace("/invoke received invocation, pushing it to the pool and wait for a lambda response")
self.invocationPool.push(LocalServerInvocation(requestId: requestId, request: body))
let forwardedHeaders = head.headers
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This variable is only used once. Maybe you can just use head.headers in the LocalServerInvocation initializer below

@manojmahapatra
Copy link
Author

manojmahapatra commented Feb 18, 2026

Hi @sebsto, thanks for taking a look. As suggested I've also added an example that does not depend on the API gateway, and updated relevant docs/README. Tested locally, working as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🔨 semver/patch No public API change.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants