-
Notifications
You must be signed in to change notification settings - Fork 494
Description
Describe the bug
I have a simple "Hello world" lambda (c#) that works when invoking it via a function url. However, once I try to invoke it via API Gateway (lambda integration), I get "Object reference not set to an instance of an object" from APIGatewayHttpApiV2ProxyFunction.MarshallRequest.
Regression Issue
- Select this option if this issue appears to be a regression.
Expected Behavior
Messages from API Gateway are processed properly.
Current Behavior
Null reference error
Reproduction Steps
- Create a lambda using the attached zip
- Run dotnet lambda deploy-function from the project directory
- Navigate to the function in AWS Console, create a Function URL
- Invoke the lambda using the Function URL from a browser (should see "Hello from AWS Lambda!")
- Copy the Lambda ARN so you can map an API Gateway "proxy" call to it.
- Got API Gateway, create a REST API.
- Map a resource as a "proxy" resource.
- Add an "ANY" method to the resource.
- Configure the "ANY" method to proxy calls to the lambda ARN
- Test the call using the "Test" tab, a GET to the root of the API
- Should get "Object reference not set to an instance of an object" error.
I've tried setting up the lambda using services.AddAWSLambdaHosting(LambdaEventSource.RestApi); and services.AddAWSLambdaHosting(LambdaEventSource.RestApi) and services.AddAWSLambdaHosting(LambdaEventSource.HttpApi)...same result.
Possible Solution
No suggestions...but the stack trace I get doesn't include file line numbers...that would be helpful. The stacktrace I get is this:
2025-02-19T20:03:33.732Z 7af2e7e1-d232-4fb4-a1b6-882286c3dd37 fail System.NullReferenceException: Object reference not set to an instance of an object.
at Amazon.Lambda.AspNetCoreServer.APIGatewayHttpApiV2ProxyFunction.MarshallRequest(InvokeFeatures features, APIGatewayHttpApiV2ProxyRequest apiGatewayRequest, ILambdaContext lambdaContext)
at Amazon.Lambda.AspNetCoreServer.AbstractAspNetCoreFunction`2.FunctionHandlerAsync(TREQUEST request, ILambdaContext lambdaContext)
at Amazon.Lambda.RuntimeSupport.HandlerWrapper.<>c__DisplayClass26_0`2.<<GetHandlerWrapper>b__0>d.MoveNext()
--- End of stack trace from previous location ---
Additional Information/Context
Here is how I set up the Integration request for my api gateway method. I have tried setting "Lambda proxy integration" to true and false...same result.
AWS .NET SDK and/or Package version used
Amazon.Lambda.AspNetCoreServer.Hosting version 1.7.3
Dotnet 8
Targeted .NET Platform
.net 8
Operating System and version
x86_64