Null Reference Exception from APIGatewayProxyFunction

Viewed 3117

I finally managed to get my API into a state where I can upload it to AWS Lambda, and then I get the error below whenever I try to use the API Gateway to test it.

{
  "errorType": "AggregateException",
  "errorMessage": "One or more errors occurred. (Object reference not set to an instance of an object.)",
  "stackTrace": [
    "at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)",
    "at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)",
    "at lambda_method(Closure , Stream , Stream , ContextInfo )"
  ],
  "cause": {
    "errorType": "NullReferenceException",
    "errorMessage": "Object reference not set to an instance of an object.",
    "stackTrace": [
      "at Amazon.Lambda.AspNetCoreServer.APIGatewayProxyFunction.MarshallRequest(InvokeFeatures features, APIGatewayProxyRequest apiGatewayRequest)",
      "at Amazon.Lambda.AspNetCoreServer.APIGatewayProxyFunction.<FunctionHandlerAsync>d__12.MoveNext()"
    ]
  }
}

code:

public class LambdaEntryPoint : Amazon.Lambda.AspNetCoreServer.APIGatewayProxyFunction
{
    protected override void Init(IWebHostBuilder builder)
    {
        try
        {
            builder
                .UseContentRoot(Directory.GetCurrentDirectory())
                .UseStartup<Startup>()
                .UseApiGateway();
        }
        catch (Exception ex)
        {
            LambdaLogger.Log("Exception throw in LambdaEntryPoint: " + ex);
        }
    }
}

I don't get any exceptions logged from my Startup or LambdaEntryPoint. I'm really new to AWS, so I'm not sure what else to check.

Any ideas on this one?

1 Answers
Related