Description
Is there an existing issue for this?
- I have searched the existing issues
Current Behavior
When throwing a custom exception (python 3.12), SFN allows you to catch them by name for flow redirection.
Error being thrown:
`
{
2 | | "resourceType": "lambda",
3 | | "resource": "invoke",
4 | | "error": "Exception",
5 | | "cause": {
6 | | "errorMessage": "Test",
7 | | "errorType": "MoveableException",
8 | | "requestId": "ad733d94-fda4-46ff-9e41-6091e79d7de5",
9 | | "stackTrace": [
10 | | " File "/var/lang/lib/python3.12/site-packages/aws_lambda_powertools/logging/logger.py", line 447, in decorate\n return lambda_handler(event, context, *args, **kwargs)\n",
11 | | " File "/var/task/fetch_job.py", line 25, in lambda_handler\n status_code, data = processor.fetch(job_data=data, config=config)\n",
12 | | " File "/var/task/processors/base_class.py", line 23, in wrapper\n return method(*args, **kwargs)\n",
13 | | " File "/var/task/processors/base_class.py", line 23, in wrapper\n return method(*args, **kwargs)\n",
14 | | " File "/var/task/processors/job_processor.py", line 168, in fetch\n raise MoveableException("Test")\n"
15 | | ]
16 | | }
17 | | }
`
Relevant definition:
"Catch": [ { "ErrorEquals": [ "MoveableException" ], "Next": "MoveJob", "ResultPath": "$.fetch_job.output" }, { "ErrorEquals": [ "Exception" ], "Next": "NotifyFailure", "ResultPath": "$.failure.output" },
This flow is validated on live AWS environments.
Expected Behavior
When a known custom exception is thrown and defined in the SFN definition block, it should act accordingly.
How are you starting LocalStack?
With a docker-compose file
Steps To Reproduce
Define a step function definition with simple catch/retry on a custom exception on a lambda invocation with a catch block mirroring the provided above.
Lambda:
`
import requests
import os
import json
def lambda_handler(event, context):
print(event)
raise MoveableException("Test")
class MoveableException(Exception):
def init(self, message: str):
super().init(message)
`
Environment
- OS: Windows WSL Ubuntu 20.04.6 LTS
- LocalStack:
LocalStack version: 4.0.2
LocalStack Docker image sha: sha256:aa6b30e7e7e3aa25e6eb4b6ada4b9c93646531284df7e9541e1d9e9f6b94fe04
LocalStack build date:
LocalStack build git hash:
Anything else?
Additional log:
2024-11-27 12:31:16 2024-11-27T10:31:16.787 ERROR --- [ad-22 (eval)] l.s.s.a.c.eval_component : Exception=FailureEventException, Error=FetchJob FAILED, Details={"taskFailedEventDetails": {"error": "FetchJob FAILED", "cause": "CSV Fetch Job Failed"}} at '(StateFail| {'comment': None, 'input_path': (InputPathBase| {'path': '$'}, 'output_path': (OutputPathBase| {'output_path': '$'}, 'state_entered_event_type': <HistoryEventType.FailStateEntered: 'FailStateEntered'>, 'state_exited_event_type': None, 'cause': (CauseConst| {'value': 'CSV Fetch Job Failed'}, 'error': (ErrorConst| {'value': 'FetchJob FAILED'}, 'name': 'JobFailed', 'query_language': (QueryLanguage| {'query_language_mode': QueryLanguageMode.JSONPath(130)}, 'state_type': <StateType.Fail: 18>, 'continue_with': <localstack.services.stepfunctions.asl.component.state.state_continue_with.ContinueWithNext object at 0x7fdae6a64bd0>, 'assign_decl': None, 'output': None}'
docker-compose:
localstack:
image: localstack/localstack:4.0.2
ports:
- 14566:4566 # LocalStack Gateway
- 14510-14559:4510-4559 # external services port range
expose:
- 4566
environment:
DEBUG: 0
SERVICES: s3,stepfunctions,lambda,iam,events,logs
AWS_DEFAULT_REGION: eu-central-1
S3_SKIP_SIGNATURE_VALIDATION: 1
DOCKER_HOST: "unix:///var/run/docker.sock"
volumes:
- data-localstack:/var/lib/localstack
- /var/run/docker.sock:/var/run/docker.sock
- ./.dc/localstack/init:/etc/localstack/init
- ./.dc/localstack/data:/data