Skip to content

fix: simulate lambda behavior for empty payload#834

Merged
normj merged 1 commit intoaws:devfrom
russau:issue-empty-payload
Mar 22, 2021
Merged

fix: simulate lambda behavior for empty payload#834
normj merged 1 commit intoaws:devfrom
russau:issue-empty-payload

Conversation

@russau
Copy link
Copy Markdown
Contributor

@russau russau commented Mar 13, 2021

When you invoke a function with no payload the Lambda service passes {} (an empty json object) to your handler input parameter. The LambdaTestTool currently sends a null parameter not matching the way the service works.

For example, the function below is configured with DefaultLambdaJsonSerializer. If you invoke with an empty payload in the LambdaTestTool the input parameter is null. Doing the the same in the Lambda service the input parameter is {} deserialized, which gives you an instance of APIGatewayProxyRequest with none of the properties set.

public async Task<APIGatewayProxyResponse> FunctionHandler(APIGatewayProxyRequest input, ILambdaContext context)

Description of changes:

  • LambdaExecutor.cs - BuildParameters now passes {} for an empty payload
  • InvokeFunctionTests.cs - WithEventParameterTest tests a method that takes an S3Event with an empty payload
  • FunctionSignatureExamples.csproj - added reference to Amazon.Lambda.S3Events
  • InstanceMethods.cs - added method that take an S3Event

@normj normj changed the base branch from master to dev March 22, 2021 22:18
@normj normj changed the base branch from dev to master March 22, 2021 22:18
@normj normj changed the base branch from master to dev March 22, 2021 22:27
@normj normj merged commit 9ce3896 into aws:dev Mar 22, 2021
@normj
Copy link
Copy Markdown
Member

normj commented Mar 22, 2021

Merged into dev branch to go out in next release.

@normj
Copy link
Copy Markdown
Member

normj commented Mar 25, 2021

This PR was released as part of version 0.11.2 of the test tool.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants