-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
StepFunctions: Fix ErrorName Value for Lambda Task Errors #11957
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
LocalStack Community integration with Pro 2 files ± 0 2 suites ±0 34m 58s ⏱️ - 1h 16m 1s Results for commit 70b8455. ± Comparison against base commit 892eb4d. This pull request removes 2511 and adds 2 tests. Note that renamed tests count towards both.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Nothing that can't be done in a follow-uo
@@ -53,6 +48,40 @@ def test_raise_exception( | |||
exec_input, | |||
) | |||
|
|||
@markers.aws.validated | |||
def test_raise_custom_exception( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add a JSONata test to this as well in a follow-up? Curious if the $states.errorOutput
works here too.
if isinstance(ex, ClientError): | ||
error_name = CustomErrorName(error) | ||
cause = ex.response["Error"]["Message"] | ||
elif isinstance(ex, lambda_eval_utils.LambdaFunctionErrorException): | ||
cause = ex.payload | ||
elif isinstance(ex, ClientError): | ||
try: | ||
cause_object = json.loads(cause) | ||
error = cause_object["errorType"] | ||
except Exception as ex: | ||
LOG.warning( | ||
"Could not retrieve 'errorType' field from LambdaFunctionErrorException object: %s", | ||
ex, | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Could be worth unifying this function and the above to prevent duplication in both the StateTaskLambda
and StateTaskServiceLambda
Motivation
Currently, the SFN v2 interpreter incorrectly assigns the error name "Exception" to Lambda task failures that result in a LambdaFunctionErrorException, rather than utilising the exception's errorType value. This limitation prevents users from catching or retrying Lambda task failures using custom exception values, as reported in this issue. These changes address the error name computation, correcting the behaviour, and introduce relevant tests for both legacy Lambda invocations and service task Lambda invocations.
Changes