Working in Node.js with AWS lambdas, I know:
My Desired Goal
Besides the error information, I want information from both the Lambda Context and the Step Function Context for the Lambda and Step State that is erroring (so specifically from the State
key, as the Execution
, StateMachine
, and Task
are all the same for any step) to be added to the final output result of a Catch to pass on to the Next step after.
The Challenge Faced in Achieving This Goal
However, it turns out that if Step Function Context is added using Parameters to the lambda input, that changed input it is still not accessible using ResultPath, as ResultPath only brings in the original input to the Step State, not the input as transformed by Parameters! You can test this with the data flow simulator (you need to be logged into an AWS account to utilize that). And of course a Pass state between the Catch and its Next call would no longer have access to the previous State Context that errored.
With my current codebase, I believe I have a workaround way of getting the Lambda Context fairly easily without a significant change as that is already being passed and used. However, accessing the Step Function Context through the lambda (via a Parameter passing to its input) would require hundreds of lines of code change in handlers and associated code to utilize it.
Ultimate Question
Is there some way I'm missing to directly add the Step Function Context from the State that is erroring to the Catch statement result, while also maintaining input and error info as is common in Catch statement use of ResultPath
?
Unfortunately, I don't know of a way to make the Step Functions context object from the failing state available in the fallback state. The best workaround I can suggest, admittedly not great, would be to have a dedicated Pass state as Fallback (i.e., intermediary between your failing state and the state you want to handle the error condition) where you could augment context such as the name of the failing state.
I'll pass this scenario on to the team as well to see how we can improve in the future.