- Newest
- Most votes
- Most comments
Unfortunately there is no direct way to access the full HTTP response details in the error object passed to the catch block in Step Functions. The error object contains only the basic error code and message.
However, there are a couple potential workarounds:
-
Enable detailed CloudWatch logging for Step Functions. This will log the full HTTP response details in the CloudWatch logs for each state. You can then search the logs using the executionId to find the response details for a failed execution.
-
Handle HTTP errors within the state machine logic. Rather than using a catch block, check the HTTP status code in the response and handle errors inline. For example:
"Check HTTP Response": {
"Type": "Task",
"Resource": "arn:aws:states:::lambda:invoke",
"Parameters": {
"FunctionName": "myFunction",
"Payload": {
"statusCode": $.statusCode,
"response": $
}
},
"Next": "HTTP 200 Success State",
"Catch": [
{
"ErrorEquals": ["States.ALL"],
"Next": "HTTP Error Handling State"
}
]
}
Then in "HTTP Error Handling State" you have access to the full response to handle errors.
- Surface the full response in the exception. In the Lambda function called by the HTTP invoke, you could catch errors and throw a custom exception containing the full response object. This custom exception will propagate to the catch block.
So in summary, while not straightforward, there are some options to get the HTTP response details you need for error handling in Step Functions. Enabling detailed CloudWatch logging is probably the simplest approach.
Relevant content
- asked 2 years ago
- Accepted Answerasked 8 months ago
- AWS OFFICIALUpdated 3 years ago
- AWS OFFICIALUpdated 3 years ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 10 months ago