- Newest
- Most votes
- Most comments
I want to highlight this to the AWS team if anyone is listening. This is a huge pain and a big roadblock for much wider adoption of this. I think this is a great service and integration, but the inability to see actual errors is a huge pain, especially during development. Many APIs respond with a generic HTTP response, such as 422
due to some validation failure. But the devil is in the details, as the saying goes. Please surface those details! Per my comment above, you can't even get this information from the logs.
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 4 months ago
- AWS OFFICIALUpdated 10 months ago
- AWS OFFICIALUpdated 3 years ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 4 months ago
Unfortunately that is not the case, and even having CW with maximum logging enabled, it will not log the error response. This is what you get in CW logs: