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
When running the st2 CLI command with -j,--jso or -y,--yaml and an error occurs, the errors are printed as strings and not JSON or YAML.
ISSUE TYPE
Bug Report
STACKSTORM VERSION
$ st2 --version
st2 2.7.2, on Python 2.7
OS / ENVIRONMENT / INSTALL METHOD
$ cat /etc/redhat-release
CentOS Linux release 7.5.1804 (Core)
Install type = puppet-st2
STEPS TO REPRODUCE
$ st2 pack get --json fdsfdsfds
Traceback (most recent call last):
File "/opt/stackstorm/st2/lib/python2.7/site-packages/st2client/commands/resource.py", line 165, in get_resource_by_pk
instance = self.manager.get_by_id(pk, **kwargs)
File "/opt/stackstorm/st2/lib/python2.7/site-packages/st2client/models/core.py", line 40, in decorate
return func(*args, **kwargs)
File "/opt/stackstorm/st2/lib/python2.7/site-packages/st2client/models/core.py", line 204, in get_by_id
self.handle_error(response)
File "/opt/stackstorm/st2/lib/python2.7/site-packages/st2client/models/core.py", line 166, in handle_error
response.raise_for_status()
File "/opt/stackstorm/st2/lib/python2.7/site-packages/requests/models.py", line 928, in raise_for_status
raise HTTPError(http_error_msg, response=self)
HTTPError: 401 Client Error: Unauthorized
MESSAGE: Unauthorized - One of Token or API key required. for url: http://127.0.0.1:9101/v1/packs/fdsfdsfds
ERROR: 401 Client Error: Unauthorized
MESSAGE: Unauthorized - One of Token or API key required. for url: http://127.0.0.1:9101/v1/packs/fdsfdsfds
$ st2 login -j -w st2admin
Password:
Logged in as st2admin
$ st2 pack get --json fdsfsdfsd
Pack "fdsfsdfsd" is not found.
EXPECTED RESULTS
Error messages to be formated as JSON / YAML so they can be parsed programatically.
Example:
$ st2 pack get --json fdsfsdfsd
{
"success": false.
"failed": true,
"error": {
"type": "pack_not_found",
"message": "Pack \"fdsfsdfsd\" is not found."
}
}
Example:
$ st2 pack get --json fdsfsdfsd
{
"success": false.
"failed": true,
"error": {
"type": "unauthorized",
"http_status": 401,
"message": "Unauthorized - One of Token or API key required. for url: http://127.0.0.1:9101/v1/packs/fdsfdsfds""exception_type": "requests.HTTPError""traceback": [
"Traceback (most recent call last):",
" File \"/opt/stackstorm/st2/lib/python2.7/site-packages/st2client/commands/resource.py\", line 165, in get_resource_by_pk",
" instance = self.manager.get_by_id(pk, **kwargs)",
" File \"/opt/stackstorm/st2/lib/python2.7/site-packages/st2client/models/core.py\", line 40, in decorate",
" return func(*args, **kwargs)",
" File \"/opt/stackstorm/st2/lib/python2.7/site-packages/st2client/models/core.py\", line 204, in get_by_id",
" self.handle_error(response)",
" File \"/opt/stackstorm/st2/lib/python2.7/site-packages/st2client/models/core.py\", line 166, in handle_error",
" response.raise_for_status()",
" File \"/opt/stackstorm/st2/lib/python2.7/site-packages/requests/models.py\", line 928, in raise_for_status",
" raise HTTPError(http_error_msg, response=self)"
]
}
}
The text was updated successfully, but these errors were encountered:
I think it's a good feature request, but it won't be totally straight forward to implement since --json flag was really mostly intended just for list and get one commands.
Supporting it in every command will require quite some refactoring.
SUMMARY
When running the
st2
CLI command with-j,--jso
or-y,--yaml
and an error occurs, the errors are printed as strings and not JSON or YAML.ISSUE TYPE
STACKSTORM VERSION
OS / ENVIRONMENT / INSTALL METHOD
Install type = puppet-st2
STEPS TO REPRODUCE
EXPECTED RESULTS
Error messages to be formated as JSON / YAML so they can be parsed programatically.
Example:
Example:
The text was updated successfully, but these errors were encountered: