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): resolve indexed context paths (#1215)
Felix Plajerf64735df5946
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex e127f41b..5eb374ea 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -7,6 +7,9 @@ Versioning follows [Semantic Versioning](https://semver.org/).## [Unreleased]+### Fixed+- **Step Functions — context object paths now resolve array indexes** — JSONPath references such as `$$.Map.Item.Value.values[0].name` returned `null` because context paths used a separate dotted-key-only resolver. Context paths now retain their distinct `$$.` root while sharing the standard path traversal, so indexed references work in `ItemSelector` fields and intrinsic-function arguments. Contributed by @felixp-square.+## [1.4.7] — 2026-07-26### Addeddiff --git a/ministack/services/stepfunctions.py b/ministack/services/stepfunctions.pyindex b12d48c5..57736de2 100644--- a/ministack/services/stepfunctions.py+++ b/ministack/services/stepfunctions.py@@ -3734,14 +3734,7 @@ def _resolve_params_obj(template, data, ctx=None):def _resolve_ctx_path(path, ctx):if not path.startswith("$$."):return None- parts = path[3:].split(".")- cur = ctx- for p in parts:- if isinstance(cur, dict) and p in cur:- cur = cur[p]- else:- return None- return cur+ return _resolve_path(path[1:], ctx)# ===================================================================diff --git a/tests/test_stepfunctions.py b/tests/test_stepfunctions.pyindex a20a5f27..1afa8750 100644--- a/tests/test_stepfunctions.py+++ b/tests/test_stepfunctions.py@@ -5694,6 +5694,61 @@ def test_sfn_map_iterations_proceed_under_non_default_account_id():sfn.delete_state_machine(stateMachineArn=sm)+def test_sfn_map_item_selector_context_path_resolves_array_index(sfn):+ """ItemSelector context paths must traverse arrays within the Map item."""+ uid = _uuid_mod.uuid4().hex[:8]+ sm = sfn.create_state_machine(+ name=f"map-context-array-index-{uid}",+ definition=json.dumps({+ "StartAt": "ProjectItems",+ "States": {+ "ProjectItems": {+ "Type": "Map",+ "ItemsPath": "$.items",+ "ItemSelector": {+ "expected.$": "$.expected",+ "observed.$": (+ "$$.Map.Item.Value.values[0].name"+ ),+ "formattedObserved.$": (+ "States.Format('{}', "+ "$$.Map.Item.Value.values[0].name)"+ ),+ },+ "Iterator": {+ "StartAt": "Echo",+ "States": {"Echo": {"Type": "Pass", "End": True}},+ },+ "End": True,+ }+ },+ }),+ roleArn="arn:aws:iam::000000000000:role/r",+ )["stateMachineArn"]+ try:+ exec_resp = sfn.start_execution(+ stateMachineArn=sm,+ name=f"e-{uid}",+ input=json.dumps({+ "expected": "first",+ "items": [{+ "values": [{+ "name": "first",+ }],+ }],+ }),+ )+ desc = _wait_sfn(sfn, exec_resp["executionArn"], timeout=10)+ assert desc["status"] == "SUCCEEDED"+ assert json.loads(desc["output"]) == [{+ "expected": "first",+ "observed": "first",+ "formattedObserved": "first",+ }]+ finally:+ sfn.delete_state_machine(stateMachineArn=sm)++# ---------------------------------------------------------------------------# JSONata variable assignment (`Assign` field + `$variable` refs) — issue #645# ---------------------------------------------------------------------------