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: apply Assign in mock path for JSONata Task states (#902)
Adrien Missemera7254379dbce
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 4f4acf2e..34153ae8 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -8,6 +8,7 @@ Versioning follows [Semantic Versioning](https://semver.org/).## [Unreleased]### Fixed+- **Step Functions — `Assign` is now applied in the mock execution path for JSONata Task states** — when `SFN_MOCK_CONFIG` was active, `_apply_state_assign` was never called on the mock return branch, so any `Assign` block in a JSONata Task state was silently skipped; downstream states referencing the assigned variables failed with `States.QueryEvaluationError: Undefined variable`. The mock branch now mirrors the real execution path by calling `_apply_state_assign` after `_apply_jsonata_output`.- **Step Functions — Pass state `Parameters` now resolve context object paths** — `$$.*` references resolved to `null` in Pass states because `_execute_pass` applied `Parameters` without forwarding the execution context. It now forwards the context correctly when evaluating `Parameters`, fixing context object resolution for Pass states.- **CloudFormation — `DescribeStackResources` now honors the `LogicalResourceId` filter** — The handler now reads the optional `LogicalResourceId` parameter and, when present, returns only the matching resource or a `ValidationError` if it does not exist in the stack.diff --git a/ministack/services/stepfunctions.py b/ministack/services/stepfunctions.pyindex e4975345..d006d89a 100644--- a/ministack/services/stepfunctions.py+++ b/ministack/services/stepfunctions.py@@ -1369,6 +1369,7 @@ def _execute_task(state_def, raw_input, execution, ctx):result=mock_result,default=mock_result,)+ _apply_state_assign(state_def, raw_input, ctx, result=mock_result)else:result = _apply_result_selector(state_def, mock_result)output = _apply_result_path(state_def, raw_input, result)diff --git a/tests/test_stepfunctions.py b/tests/test_stepfunctions.pyindex 40fd5be8..ec951cfe 100644--- a/tests/test_stepfunctions.py+++ b/tests/test_stepfunctions.py@@ -2628,6 +2628,73 @@ def test_sfn_mock_config_throw(sfn):assert desc["status"] == "FAILED"_ministack_config({"stepfunctions._sfn_mock_config": {}})+def test_sfn_mock_config_jsonata_assign_applied(sfn):+ """SFN_MOCK_CONFIG + JSONata Task with Assign — variable must be visible downstream.++ Regression: the mock execution path called _apply_jsonata_output but never+ called _apply_state_assign, so any Assign block was silently skipped.+ A downstream state reading the assigned variable would fail with+ States.QueryEvaluationError: Undefined variable.+ """+ from conftest import _ministack_config++ mock_cfg = {+ "StateMachines": {+ "qa-sfn-mock-jsonata-assign": {+ "TestCases": {+ "HappyPath": {+ "FetchData": "MockedData",+ }+ }+ }+ },+ "MockedResponses": {+ "MockedData": {+ "0": {"Return": {"value": 99}},+ }+ },+ }+ _ministack_config({"stepfunctions._sfn_mock_config": mock_cfg})++ definition = json.dumps({+ "QueryLanguage": "JSONata",+ "StartAt": "FetchData",+ "States": {+ "FetchData": {+ "Type": "Task",+ "Resource": "arn:aws:lambda:us-east-1:000000000000:function:nonexistent",+ "Assign": {"fetchedValue": "{% $states.result.value %}"},+ "Next": "UseValue",+ },+ "UseValue": {+ "Type": "Pass",+ "Output": {"result": "{% $fetchedValue %}"},+ "End": True,+ },+ },+ })+ sm_arn = sfn.create_state_machine(+ name="qa-sfn-mock-jsonata-assign",+ definition=definition,+ roleArn="arn:aws:iam::000000000000:role/r",+ )["stateMachineArn"]++ exec_arn = sfn.start_execution(+ stateMachineArn=sm_arn + "#HappyPath", input="{}",+ )["executionArn"]+ for _ in range(20):+ time.sleep(0.3)+ desc = sfn.describe_execution(executionArn=exec_arn)+ if desc["status"] != "RUNNING":+ break++ assert desc["status"] == "SUCCEEDED", (+ f"Execution failed — Assign likely not applied in mock path: {desc.get('cause')}"+ )+ output = json.loads(desc["output"])+ assert output["result"] == 99, f"Expected 99 from assigned variable, got: {output}"+ _ministack_config({"stepfunctions._sfn_mock_config": {}})+def test_sfn_test_state_pass(sfn_sync):"""TestState API — Pass state returns transformed output."""resp = sfn_sync.test_state(