I have a Step Function that takes a JSON payload. The handler accepts a Map<String, Object> and returns the same thing.
The issue I have run into is keys are lost when serializing the map back to JSON which causes me exceptions at the next step.
I have the following which transforms the input, into a common structure for the lambda:
"SearchForPersonCustomer": {
"Type": "Task",
"Resource": "arn:aws:states:::lambda:invoke",
"Parameters": {
"FunctionName": "arn:aws:lambda:us-west-2:xxxxx:function:searchForCustomer:$LATEST",
"Payload": {
"businessSearchInd": false,
"taxIdentifier.$": "$.sSN",
"firstName.$": "$.firstName",
"middleInitial.$": "$.middleInitial",
"lastName.$": "$.lastName",
"birthDate.$": "$.birthDate"
}
}
The issue is that while the field middleInitial ("middleInitial":null) is populated in the JSON, the prior steps output no longer serializes it, so when it attempts to access it, the step function fails as follows:
The JSONPath '$.middleInitial' specified for the field 'middleInitial.$' could not be found in the input
Is there a way to handle this edge case, so that if the missing field, in this case middleInitial is just assumed to be null as it translates to the payload?
Thanks