Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix TypeError in help command by handling mixed parameter types for sorting #6266

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ Other options that were renamed under `[database]` are (more details available i

Fixed
~~~~~
* Fixed #5130 by ensuring consistent sorting of action parameters in the `st2 run <action> -h` command.
Converted the `position` attribute to a string for sorting, preventing the `TypeError: '<' not supported between instances of 'str' and 'int'` error in Python 3.
* Fixed #6021 and #5327 by adding max_page_size to api_opts and added limit and offset to list_values() methods of
both action_service and sensor_service
* Fix `packs.get` action. Assumed `master` is primary branch on all packs. #6225
Expand Down
14 changes: 6 additions & 8 deletions st2client/st2client/commands/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -878,7 +878,7 @@ def transform_array(value, action_params=None, auto_dict=False):
# the 'result' to the dict type value.
if all([isinstance(x, str) and ":" in x for x in result]) and auto_dict:
result_dict = {}
for (k, v) in [x.split(":") for x in result]:
for k, v in [x.split(":") for x in result]:
# To parse values using the 'transformer' according to the type which is
# specified in the action metadata, calling 'normalize' method recursively.
if (
Expand Down Expand Up @@ -1207,13 +1207,11 @@ def _get_parameter_sort_value(self, parameters, name):
If this attribute is not available, parameter is sorted based on the
name.
"""
parameter = parameters.get(name, None)

if not parameter:
return None

sort_value = parameter.get("position", name)
return sort_value
parameter = parameters.get(name)
if parameter:
position = parameter.get("position")
return position if position is not None else name
return None

def _get_inherited_env_vars(self):
env_vars = os.environ.copy()
Expand Down
Loading