Improve st2client error messages when parameter missing type
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 6.5k
- Forks
- 787
- PR merge metrics
- No merged PRs in 30d
Description
SUMMARY
st2 run error message when action parameter has undefined type is unhelpful. Should be improved.
ISSUE TYPE
- Minor enhancement
STACKSTORM VERSION
2.10.4.
OS / ENVIRONMENT / INSTALL METHOD
Ansible.
STEPS TO REPRODUCE
Create an action that has a parameter with a default value, but no type defined, e.g. username in this action:
---
name: "wait_for_ssh"
runner_type: "python-script"
description: "Action which waits for a SSH server to become accessible. By default, if no credentials are provided, this action will try to authenticate using the system user username and key file."
enabled: true
entry_point: "wait_for_ssh.py"
parameters:
hostname:
description: "Remote hostname."
type: "string"
required: true
port:
description: "Remote SSH port."
type: "integer"
required: true
default: 22
username:
description: "Username used to authenticate."
required: true
default: "stanley"
If the action is run via CLI without specifying username, it works. If you specify a username, it throws an unhelpful error.
ACTUAL RESULTS
lhill@st2:~$ st2 run linux.wait_for_ssh hostname="127.0.0.1" port="22" username=stanley
ERROR: 'type'
I think there's three options here:
1/ Update st2client to assume that the type is string if not otherwise specified. That is what the rest of our codebase does.
2/ Update the code around here to catch this Exception & log a nicer error message
3/ Change action validation rules to enforce specification of type: parameter, rather than defaulting to string.
I think (1) is the best option, to be consistent with all other usage, and not require user updates to their existing actions. (2) is helpful. (3) should be avoided due to change in behavior requiring widespread re-work.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in st2client/st2client/commands/action.py around the referenced line and reproduce the problem with the supplied st2 run command and action definition. Determine how a missing parameter type is handled there; done means the CLI no longer reports only 'type' and follows the issue's intended behavior for omitted types.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100