Describe the bug
When invoking an ASP.NET Core Lambda through Lambda Test Tool v2 API Gateway emulator, the emulator builds an APIGatewayProxyRequest that is incomplete compared with a real API Gateway event:
RequestContext is often null / missing (no Path, HttpMethod, ApiId, Identity, etc.)
- In some paths,
Path, HttpMethod, or path-parameter / header values can be null
Amazon.Lambda.AspNetCoreServer (APIGatewayProxyFunction.MarshallRequest / path + header utilities) assumes these fields are present and throws NullReferenceException (or fails marshalling) instead of degrading safely.
This breaks the local inner loop for ASP.NET Core on Lambda behind the emulator, even when the route is a normal Lambda integration (not an HTTP proxy backend).
Regression Issue
Expected Behavior
- Emulator-built proxy events should populate a minimal but valid
RequestContext (and Path / HttpMethod), similar to API Gateway test-invoke.
Amazon.Lambda.AspNetCoreServer should null-guard Path, path parameters, and header values so incomplete events fail clearly or use safe defaults, not NRE.
Current Behavior
Marshalling crashes or misbehaves when the emulator omits RequestContext / leaves path or header values null.
Reproduction Steps
- Run Lambda Test Tool v2 with API Gateway emulator enabled.
- Configure a route to an ASP.NET Core function using
Amazon.Lambda.AspNetCoreServer (APIGatewayProxyFunction / Hosting).
- Call the route via the emulator HTTP URL (REST or HTTP API mode).
- Observe NRE / marshalling failure when
RequestContext or Path is null on the synthesized event.
Minimal observation: deserialize/inspect the event the emulator sends to the Runtime API and compare with a real API Gateway proxy event — RequestContext is missing on the emulator path.
Possible Solution
- Test Tool emulator: always set
APIGatewayProxyRequest.RequestContext (and Path / HttpMethod) when translating HTTP → Lambda event.
- AspNetCoreServer: null-safe marshalling for
Path, HttpMethod, path parameters, and multi/single-value headers.
We have a working fix on a fork (happy to open a PR once this issue exists).
Additional Information/Context
- Packages:
Amazon.Lambda.AspNetCoreServer, Amazon.Lambda.TestTool (v2 API Gateway emulator)
- Related (separate feature request): HTTP proxy integration so non-Lambda backends share the emulator origin — not this bug.
AWS .NET SDK and/or Package version used
Amazon.Lambda.AspNetCoreServer 10.2.1
Amazon.Lambda.AspNetCoreServer.Hosting 2.2.1
Amazon.Lambda.TestTool 0.15.1
Amazon.Lambda.Core 3.3.0
Amazon.Lambda.APIGatewayEvents 3.0.1
Targeted .NET Platform
.NET 10, AspNetCoreServer 10.2.1
Operating System and version
Windows 11
Describe the bug
When invoking an ASP.NET Core Lambda through Lambda Test Tool v2 API Gateway emulator, the emulator builds an
APIGatewayProxyRequestthat is incomplete compared with a real API Gateway event:RequestContextis often null / missing (noPath,HttpMethod,ApiId,Identity, etc.)Path,HttpMethod, or path-parameter / header values can be nullAmazon.Lambda.AspNetCoreServer(APIGatewayProxyFunction.MarshallRequest/ path + header utilities) assumes these fields are present and throws NullReferenceException (or fails marshalling) instead of degrading safely.This breaks the local inner loop for ASP.NET Core on Lambda behind the emulator, even when the route is a normal Lambda integration (not an HTTP proxy backend).
Regression Issue
Expected Behavior
RequestContext(and Path / HttpMethod), similar to API Gateway test-invoke.Amazon.Lambda.AspNetCoreServershould null-guardPath, path parameters, and header values so incomplete events fail clearly or use safe defaults, not NRE.Current Behavior
Marshalling crashes or misbehaves when the emulator omits
RequestContext/ leaves path or header values null.Reproduction Steps
Amazon.Lambda.AspNetCoreServer(APIGatewayProxyFunction/ Hosting).RequestContextorPathis null on the synthesized event.Minimal observation: deserialize/inspect the event the emulator sends to the Runtime API and compare with a real API Gateway proxy event —
RequestContextis missing on the emulator path.Possible Solution
APIGatewayProxyRequest.RequestContext(and Path / HttpMethod) when translating HTTP → Lambda event.Path,HttpMethod, path parameters, and multi/single-value headers.We have a working fix on a fork (happy to open a PR once this issue exists).
Additional Information/Context
Amazon.Lambda.AspNetCoreServer,Amazon.Lambda.TestTool(v2 API Gateway emulator)AWS .NET SDK and/or Package version used
Amazon.Lambda.AspNetCoreServer 10.2.1
Amazon.Lambda.AspNetCoreServer.Hosting 2.2.1
Amazon.Lambda.TestTool 0.15.1
Amazon.Lambda.Core 3.3.0
Amazon.Lambda.APIGatewayEvents 3.0.1
Targeted .NET Platform
.NET 10, AspNetCoreServer 10.2.1
Operating System and version
Windows 11