Skip to content

Commit 9dd61c3

Browse files
Fix null value in ResultPath
Fixes #45
1 parent bb06bfb commit 9dd61c3

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

src/stepfunctions/steps/states.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def to_dict(self):
6868
result = {}
6969
# Common fields
7070
for k, v in self.fields.items():
71-
if v is not None:
71+
if v is not None or k == 'result_path':
7272
k = to_pascalcase(k)
7373
if k == to_pascalcase(Field.Parameters.value):
7474
result[k] = self._replace_placeholders(v)

tests/unit/test_steps.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,4 +346,24 @@ def test_retry_fail_for_unsupported_state():
346346
c1 = Choice('My Choice')
347347

348348
with pytest.raises(ValueError):
349-
c1.add_catch(Catch(error_equals=["States.NoChoiceMatched"], next_step=Fail("ChoiceFailed")))
349+
c1.add_catch(Catch(error_equals=["States.NoChoiceMatched"], next_step=Fail("ChoiceFailed")))
350+
351+
352+
def test_result_path_none():
353+
task_state = Task('Task', resource='arn:aws:lambda:us-east-1:1234567890:function:StartLambda', result_path=None)
354+
assert task_state.to_dict() == {
355+
'Type': 'Task',
356+
'Resource': 'arn:aws:lambda:us-east-1:1234567890:function:StartLambda',
357+
'ResultPath': None,
358+
'End': True
359+
}
360+
361+
362+
def test_result_path_none_converted_to_null():
363+
task_state = Task('Task', resource='arn:aws:lambda:us-east-1:1234567890:function:StartLambda', result_path=None)
364+
assert '"ResultPath": null' in task_state.to_json()
365+
366+
367+
def test_default_result_path_not_converted_to_null():
368+
task_state = Task('Task', resource='arn:aws:lambda:us-east-1:1234567890:function:StartLambda')
369+
assert '"ResultPath": null' not in task_state.to_json()

0 commit comments

Comments
 (0)