Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ Fixed
Contributed by Tatsuma Matsuki (@mtatsuma)

* Fix dependency conflicts by updating ``requests`` (2.23.0) and ``gitpython`` (2.1.15). #4869
* Fixed serializing array parameters (bug fix) #4804, #4861, #4872

3.1.0 - June 27, 2019
---------------------
Expand Down
4 changes: 2 additions & 2 deletions st2common/st2common/util/action_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,9 +283,9 @@ def serialize_positional_argument(argument_type, argument_value):
argument_value = '1' if bool(argument_value) else '0'
else:
argument_value = ''
elif argument_type == 'list':
elif argument_type in ['array', 'list']:
# Lists are serialized a comma delimited string (foo,bar,baz)
argument_value = ','.join(argument_value) if argument_value else ''
argument_value = ','.join(map(str, argument_value)) if argument_value else ''
elif argument_type == 'object':
# Objects are serialized as JSON
argument_value = json.dumps(argument_value) if argument_value else ''
Expand Down
16 changes: 12 additions & 4 deletions st2common/tests/unit/test_action_db_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ def test_get_args(self):
'runnerint': 555
}
pos_args, named_args = action_db_utils.get_args(params, ActionDBUtilsTestCase.action_db)
self.assertListEqual(pos_args, ['20', '', 'foo', '', '', '', ''],
self.assertListEqual(pos_args, ['20', '', 'foo', '', '', '', '', ''],
'Positional args not parsed correctly.')
self.assertNotIn('actionint', named_args)
self.assertNotIn('actionstr', named_args)
Expand All @@ -340,6 +340,7 @@ def test_get_args(self):
'actionfloat': 1.5,
'actionstr': 'string value',
'actionbool': True,
'actionarray': ['foo', 'bar', 'baz', 'qux'],
'actionlist': ['foo', 'bar', 'baz'],
'actionobject': {'a': 1, 'b': '2'},
}
Expand All @@ -348,6 +349,7 @@ def test_get_args(self):
'1.5',
'string value',
'1',
'foo,bar,baz,qux',
'foo,bar,baz',
'{"a": 1, "b": "2"}',
''
Expand All @@ -361,6 +363,7 @@ def test_get_args(self):
'actionfloat': 1.5,
'actionstr': 'string value',
'actionbool': False,
'actionarray': [],
'actionlist': [],
'actionobject': {'a': 1, 'b': '2'},
}
Expand All @@ -370,6 +373,7 @@ def test_get_args(self):
'string value',
'0',
'',
'',
'{"a": 1, "b": "2"}',
''
]
Expand All @@ -383,6 +387,7 @@ def test_get_args(self):
'actionfloat': None,
'actionstr': None,
'actionbool': None,
'actionarray': None,
'actionlist': None,
'actionobject': None,
}
Expand All @@ -393,6 +398,7 @@ def test_get_args(self):
'',
'',
'',
'',
''
]
pos_args, _ = action_db_utils.get_args(params, ActionDBUtilsTestCase.action_db)
Expand All @@ -412,6 +418,7 @@ def test_get_args(self):
'',
'',
'',
'',
''
]
pos_args, named_args = action_db_utils.get_args(params, ActionDBUtilsTestCase.action_db)
Expand Down Expand Up @@ -463,9 +470,10 @@ def setup_action_models(cls):
'actionfloat': {'type': 'float', 'required': False, 'position': 1},
'actionstr': {'type': 'string', 'required': True, 'position': 2},
'actionbool': {'type': 'boolean', 'required': False, 'position': 3},
'actionlist': {'type': 'list', 'required': False, 'position': 4},
'actionobject': {'type': 'object', 'required': False, 'position': 5},
'actionnull': {'type': 'null', 'required': False, 'position': 6},
'actionarray': {'type': 'array', 'required': False, 'position': 4},
'actionlist': {'type': 'list', 'required': False, 'position': 5},
'actionobject': {'type': 'object', 'required': False, 'position': 6},
'actionnull': {'type': 'null', 'required': False, 'position': 7},

'runnerdummy': {'type': 'string', 'default': 'actiondummy'}
}
Expand Down