Ministack: Free, open-source local AWS emulator - 60+ services, Terraform compatible, real databases. Free forever. MIT licensed.
Python awsaws-emulatoraws-localaws-sdkdevtoolsdockerdynamodbec2emulatorlambdalocalstacklocalstack-alternativeministackmock-awsopen-sourcepythons3sqsterraform
fix(stepfunctions): StopExecution keeps its error and cause (#2071)
Jeff Heller0d14c53dce5c
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex c16047e0..1ae3640b 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -21,6 +21,7 @@ Versioning follows [Semantic Versioning](https://semver.org/).- **IoT — `DescribeCertificate` reports `certificateMode`** — the field was missing from the description. It is now `SNI_ONLY` for a certificate registered with `RegisterCertificateWithoutCA` and `DEFAULT` for the others, as AWS reports it. Contributed by @iot-rocket.### Fixed+- **Step Functions — `StopExecution` keeps its `error` and `cause`** — they were recorded only in the `ExecutionAborted` history event, so `DescribeExecution` of the aborted execution returned neither. They are now kept on the execution and returned by `DescribeExecution`; AWS returns the `cause` of an execution stopped with one.- **Step Functions — the first matching retrier decides** — a retrier that had used its `MaxAttempts` (or had `MaxAttempts: 0`) was skipped, so a later matching retrier such as `States.ALL` retried the error anyway. The first retrier whose `ErrorEquals` matches now decides: once it has used its attempts the state fails (or goes to its `Catch`), as the Developer Guide's error-handling examples describe.- **S3 — cross-account replication** — `PutBucketReplication` dropped `Destination.Account` and `AccessControlTranslation`, and the replica write looked the destination bucket up only in the caller's account, so a destination owned by another account stamped every object `FAILED`. The destination is now found by its bucket name in any account and the replica (object, versions, tags, annotations, on-disk files) lands in the owner's scope. A cross-account destination requires its bucket policy to grant the rule's `Role` `s3:ReplicateObject`, plus `s3:ObjectOwnerOverrideToBucketOwner` when `AccessControlTranslation` is set and the destination is not `BucketOwnerEnforced`; otherwise the source reports `FAILED`. `PutBucketReplication` / `GetBucketReplication` round-trip `Filter` (`Prefix`, `Tag`, `And`), `Priority`, `DeleteMarkerReplication`, `Destination.Account` and `AccessControlTranslation`, and the destination-versioning check at configuration time sees buckets in any account. Contributed by @pingedbrain.- **RDS Data API — MySQL `generatedFields`** — `ExecuteStatement` and `BatchExecuteStatement` always answered `generatedFields: []`, so an `INSERT` into an `AUTO_INCREMENT` table gave no way to read the new id. On the MySQL engines it now holds the id the server assigned (`[{"longValue": <id>}]`), or `[]` when none was assigned; `BatchExecuteStatement` reports it in each parameter set's update result. Aurora PostgreSQL still returns `[]`: the API reference says it does not support `generatedFields` and points to `RETURNING`.diff --git a/ministack/services/stepfunctions.py b/ministack/services/stepfunctions.pyindex c9e3ded2..c191d4d9 100644--- a/ministack/services/stepfunctions.py+++ b/ministack/services/stepfunctions.py@@ -706,6 +706,8 @@ def _stop_execution(data):stop_date = now_iso()execution["status"] = "ABORTED"execution["stopDate"] = stop_date+ execution["error"] = data.get("error")+ execution["cause"] = data.get("cause")_add_event(execution, "ExecutionAborted", {"executionAbortedEventDetails": {"error": data.get("error", ""),diff --git a/tests/test_stepfunctions.py b/tests/test_stepfunctions.pyindex 36ee6aa2..15de58b8 100644--- a/tests/test_stepfunctions.py+++ b/tests/test_stepfunctions.py@@ -353,6 +353,10 @@ def test_sfn_stop_execution_v2(sfn):sfn.stop_execution(executionArn=ex["executionArn"], error="UserAbort", cause="test stop")desc = sfn.describe_execution(executionArn=ex["executionArn"])assert desc["status"] == "ABORTED"+ assert (desc["error"], desc["cause"]) == ("UserAbort", "test stop")+ events = sfn.get_execution_history(executionArn=ex["executionArn"])["events"]+ aborted = next(e for e in events if e["type"] == "ExecutionAborted")+ assert aborted["executionAbortedEventDetails"] == {"error": "UserAbort", "cause": "test stop"}def test_sfn_get_execution_history_v2(sfn):definition = json.dumps(