I am working on a Step Function that begins by attempting to get an item from my DynamoDB based on a passed input.
If the item exists, all is well.
However, I am having trouble handling the error if the item does NOT exist, mainly because the output result is transformed via ResultSelector and ResultPath.
When the function fails, the output looks something like this:
The JSONPath '$.Item.status.S' specified for the field 'status.$' could not be found in the input
And the error thrown falls under the reason States.Runtime
.
So, naturally, I attempt to catch this this error and set a fallback state to what is ultimately my result handler lambda, but the step function never leaves that first state--it just fails and never falls back...what should I do?
Thanks!
According to the docs, States.Runtime error are not retriable, and will always cause the execution to fail
From my understanding, your States.Runtime is coming from the "ResultSelector" portion of your state. I suggest not transforming the result in that state and rather pass the DynamoDB output directly to a next state which would be a choice state. The choice state can then check for the existence of the '$.Item.status' and diverge to separate states to handle the existence and non-existence