You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On some cases, when trying to display the help st2 run action pack.action -h on an action that has ordered parameters like this one from the librenms pack
STACKSTORM VERSION
Paste the output of st2 --version:
st2 --version
st2 3.3.0, on Python 3.9.1
OS, environment, install method
Post what OS you are running this on, along with any other relevant information/
print('ERROR: Unable to print help for action "%s". %s'%
Help by amanda on the Slack channel:
Added some debug after reproducing:
Traceback (most recent call last):
File "/opt/stackstorm/st2/lib/python3.6/site-packages/st2client/commands/action.py", line 771, in _print_help
names=optional)
File "/opt/stackstorm/st2/lib/python3.6/site-packages/st2client/commands/action.py", line 898, in _sort_parameters
sorted_parameters = sorted(names, key=lambda name:
TypeError: '<' not supported between instances of 'str' and 'int'
It looks like it's to do with the position parameters, the sort uses name or position depending on which is given.
If I get rid of the position attributes, then the help works.
So looks like a bug that when it does the sort it indices some by position and others by name, and then can't sort. As presumably the parameters from the runner are indexed by name.
Could you raise an issue on ST2 for this? I think it's probalby that in python 2 it would allow this comparison, but on python 3 then we probably need to convert the position to a string in that sort. So it should be a simple fix to ST2 if you want to take a look.
The text was updated successfully, but these errors were encountered:
kedare
changed the title
Issue with action help generation when having ordered parameter
Issue with action help generation when having ordered parameters
Jan 28, 2021
A quick hack to resolve this on a local system was to change st2client/commands/action.py to
def _get_parameter_sort_value(self, parameters, name):
"""
Return a value which determines sort order for a particular parameter.
By default, parameters are sorted using "position" parameter attribute.
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 = str(parameter.get('position', name))
return sort_value
kedare
changed the title
Issue with action help generation when having ordered parameters
Issue with action help display when having ordered optional parameters
Jan 28, 2021
SUMMARY
On some cases, when trying to display the help
st2 run action pack.action -h
on an action that has ordered parameters like this one from thelibrenms
packSTACKSTORM VERSION
Paste the output of
st2 --version
:OS, environment, install method
Post what OS you are running this on, along with any other relevant information/
Steps to reproduce the problem
Install the following pack : https://github.com/kedare/stackstorm-librenms
Try to run the following command :
Expected Results
The help to be shown
Actual Results
The following output is displayed
Investigation
The error is catched there
st2/st2client/st2client/commands/action.py
Line 779 in 5c4e5f8
Help by amanda on the Slack channel:
The text was updated successfully, but these errors were encountered: