Skip to content

Commit f996e14

Browse files
Fix null values in InputPath and OutputPath
1 parent bf62ca9 commit f996e14

File tree

2 files changed

+26
-7
lines changed

2 files changed

+26
-7
lines changed

src/stepfunctions/steps/states.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,10 @@ def _replace_placeholders(self, params):
6666

6767
def to_dict(self):
6868
result = {}
69+
fields_accepted_as_none = ('result_path', 'input_path', 'output_path')
6970
# Common fields
7071
for k, v in self.fields.items():
71-
if v is not None or k == 'result_path':
72+
if v is not None or k in fields_accepted_as_none:
7273
k = to_pascalcase(k)
7374
if k == to_pascalcase(Field.Parameters.value):
7475
result[k] = self._replace_placeholders(v)

tests/unit/test_steps.py

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -349,22 +349,40 @@ def test_retry_fail_for_unsupported_state():
349349
c1.add_catch(Catch(error_equals=["States.NoChoiceMatched"], next_step=Fail("ChoiceFailed")))
350350

351351

352-
def test_result_path_none():
353-
task_state = Task('Task', resource='arn:aws:lambda:us-east-1:1234567890:function:StartLambda', result_path=None)
352+
def test_paths_none():
353+
task_state = Task('Task', resource='arn:aws:lambda:us-east-1:1234567890:function:StartLambda',
354+
result_path=None,
355+
input_path=None,
356+
output_path=None)
354357
assert 'ResultPath' in task_state.to_dict()
355358
assert task_state.to_dict()['ResultPath'] is None
356359

360+
assert 'InputPath' in task_state.to_dict()
361+
assert task_state.to_dict()['InputPath'] is None
357362

358-
def test_result_path_none_converted_to_null():
359-
task_state = Task('Task', resource='arn:aws:lambda:us-east-1:1234567890:function:StartLambda', result_path=None)
363+
assert 'OutputPath' in task_state.to_dict()
364+
assert task_state.to_dict()['OutputPath'] is None
365+
366+
367+
def test_paths_none_converted_to_null():
368+
task_state = Task('Task', resource='arn:aws:lambda:us-east-1:1234567890:function:StartLambda',
369+
result_path=None,
370+
input_path=None,
371+
output_path=None)
360372
assert '"ResultPath": null' in task_state.to_json()
373+
assert '"InputPath": null' in task_state.to_json()
374+
assert '"OutputPath": null' in task_state.to_json()
361375

362376

363-
def test_default_result_path_not_included():
377+
def test_default_paths_not_included():
364378
task_state = Task('Task', resource='arn:aws:lambda:us-east-1:1234567890:function:StartLambda')
365379
assert 'ResultPath' not in task_state.to_dict()
380+
assert 'InputPath' not in task_state.to_dict()
381+
assert 'OutputPath' not in task_state.to_dict()
366382

367383

368-
def test_default_result_path_not_converted_to_null():
384+
def test_default_paths_not_converted_to_null():
369385
task_state = Task('Task', resource='arn:aws:lambda:us-east-1:1234567890:function:StartLambda')
370386
assert '"ResultPath": null' not in task_state.to_json()
387+
assert '"InputPath": null' not in task_state.to_json()
388+
assert '"OutputPath": null' not in task_state.to_json()

0 commit comments

Comments
 (0)