Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: simulate lambda behavior for empty payload #834

Merged
merged 1 commit into from
Mar 22, 2021

Conversation

russau
Copy link
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
Member

normj commented Mar 22, 2021

Merged into dev branch to go out in next release.

@normj
Copy link
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.

None yet

2 participants