aws-lambda-dotnet icon indicating copy to clipboard operation
aws-lambda-dotnet copied to clipboard

LambdaBootstrapBuilder documentation is wrong / misleading

Open tmitchel2 opened this issue 1 year ago • 1 comments

Describe the issue

https://docs.aws.amazon.com/lambda/latest/dg/csharp-handler.html has a section which has the following

await LambdaBootstrapBuilder.Create<APIGatewayProxyRequest>(Handler, new DefaultLambdaJsonSerializer())
    .Build()
    .RunAsync();

This is incorrect because the handler will be treated as not having a response type (will just be treated as Task) and the response will not serialized back to the api gateway. This then leads to a malformed response exception which is incredibly hard to diagnose. TBH the code allows for this behaviour a bit too readily.

Anyway the documentation should include the response type as a generic to work correctly...

await LambdaBootstrapBuilder.Create<APIGatewayProxyRequest, APIGatewayProxyResponse>(Handler, new DefaultLambdaJsonSerializer())
    .Build()
    .RunAsync();

Links

https://docs.aws.amazon.com/lambda/latest/dg/csharp-handler.html

tmitchel2 avatar Oct 02 '24 12:10 tmitchel2

Hi @tmitchel2,

Thank you for submitting the issue. We'll verify the proposed documentation changes and forward the request to the service team accordingly.

Regards, Chaitanya

bhoradc avatar Oct 02 '24 16:10 bhoradc

@tmitchel2 I think you are correct that example at Executable assembly handlers is missing the response return type at the below code:

await LambdaBootstrapBuilder.Create<APIGatewayProxyRequest>(Handler, new DefaultLambdaJsonSerializer())
    .Build()
    .RunAsync();

It should be updated to below code as you suggested:

await LambdaBootstrapBuilder.Create<APIGatewayProxyRequest, ILambdaContext, APIGatewayProxyResponse>(Handler, new DefaultLambdaJsonSerializer())
    .Build()
    .RunAsync();

ashishdhingra avatar Nov 13 '24 23:11 ashishdhingra

@tmitchel2 I have submitted the feedback request on the documentation page Executable assembly handlers so that it goes to the correct team to update the documentation pages. Closing this issue since the request is submitted to the correct team.

ashishdhingra avatar Nov 15 '24 18:11 ashishdhingra

Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.

github-actions[bot] avatar Nov 15 '24 18:11 github-actions[bot]