aws / aws/aws-toolkit-azure-devops
AWS Lambda Invoke Function - Invalid Payload
- Dominant language
- TypeScript
- Stars
- 258
- Forks
- 114
- PR merge metrics
- No merged PRs in 30d
Description
Hi there
I have a lambda function that accepts a payload of type TaskDefinitionRevisionRequest
```
public class TaskDefinitionRevisionRequest
{
public TaskDefinitionRevisionRequest()
{
IsBasedOnLatestRevision = true;
}
public bool IsBasedOnLatestRevision { get; set; }
public int BasedOnRevisionNumber { get; set; }
public string TaskDefinitionName { get; set; }
public string DockerImage { get; set; }
}
```
When invoking the function through VSTS with payload
```
{
"IsBasedOnLatestRevision": true,
"BasedOnRevisionNumber": 0,
"TaskDefinitionName": "MyTaskName",
"DockerImage": "22222222222.dkr.ecr.eu-west-1.amazonaws.com/ghos/api/notifications:50841"
}
```
I get the following error
```
Error converting the Lambda event JSON payload to type MiX.GHOS.Notifications.Lambdas.Entities.TaskDefinitionRevisionRequest: Error converting value "
{
"IsBasedOnLatestRevision": true,
"BasedOnRevisionNumber": 0,
"TaskDefinitionName": "MyTaskName",
"DockerImage": "22222222222.dkr.ecr.eu-west-1.amazonaws.com/ghos/api/notifications:50841"
}
" to type 'MiX.GHOS.Notifications.Lambdas.Entities.TaskDefinitionRevisionRequest'. Path '', line 1, position 215.: JsonSerializerException
at Amazon.Lambda.Serialization.Json.JsonSerializer.Deserialize[T](Stream requestStream)
at lambda_method(Closure , Stream , Stream , LambdaContextInternal )
```
The strange this is, using this exact payload in the local Lambda test runner and the test invocation on the Lambda AWS Console works 100%
It would seem as if this task changes the payload somehow, or mal-forms it somehow before invoking the Lambda.
I have also created a UnitTest that uses the Amazon.Lambda.Serialization.Json.JsonSerializer.Deserialize method to deserialize the same payload into the object without issues.
Contributor guide
Research direction
Start at the AWS Lambda invocation task in the Azure DevOps extension and compare the payload sent by VSTS with the payload accepted by Amazon.Lambda.Serialization.Json.JsonSerializer.Deserialize. Reproduce the issue using the reported VSTS payload and verify that the Lambda receives valid JSON matching TaskDefinitionRevisionRequest.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, azure, typescript
- Domain
- ci-cd, cloud
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100