st2 icon indicating copy to clipboard operation
st2 copied to clipboard

Minor: Cleaner response for already addressed inquiries

Open humblearner opened this issue 7 years ago • 1 comments

We don't need Traceback here:

$ st2 inquiry respond 59ee3b52909a501cdb2d87e9
Traceback (most recent call last):
  File "/home/vagrant/git/st2/st2client/st2client/commands/resource.py", line 162, in get_resource_by_pk
    instance = self.manager.get_by_id(pk, **kwargs)
  File "/home/vagrant/git/st2/st2client/st2client/models/core.py", line 39, in decorate
    return func(*args, **kwargs)
  File "/home/vagrant/git/st2/st2client/st2client/models/core.py", line 204, in get_by_id
    self.handle_error(response)
  File "/home/vagrant/git/st2/st2client/st2client/models/core.py", line 165, in handle_error
    response.raise_for_status()
  File "/home/vagrant/git/st2/virtualenv/lib/python2.7/site-packages/requests/models.py", line 928, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
HTTPError: 400 Client Error: Bad Request
MESSAGE: Inquiry 59ee3b52909a501cdb2d87e9 has already been responded to for url: http://127.0.0.1:9101/exp/inquiries/59ee3b52909a501cdb2d87e9
ERROR: Resource with id "59ee3b52909a501cdb2d87e9" doesn't exist.

something like following should suffice:

$ st2 inquiry respond -r '{"secondfactor": "bar"}' 59ee3b52909a501cdb2d87e9
ERROR: 400 Client Error: Bad Request
MESSAGE: Inquiry 59ee3b52909a501cdb2d87e9 has already been responded to for url: http://127.0.0.1:9101/exp/inquiries/59ee3b52909a501cdb2d87e9

Same for:

$ st2 inquiry get 59ee3b5a909a501d270e9057
Traceback (most recent call last):
  File "/home/vagrant/git/st2/st2client/st2client/commands/resource.py", line 162, in get_resource_by_pk
    instance = self.manager.get_by_id(pk, **kwargs)
  File "/home/vagrant/git/st2/st2client/st2client/models/core.py", line 39, in decorate
    return func(*args, **kwargs)
  File "/home/vagrant/git/st2/st2client/st2client/models/core.py", line 204, in get_by_id
    self.handle_error(response)
  File "/home/vagrant/git/st2/st2client/st2client/models/core.py", line 165, in handle_error
    response.raise_for_status()
  File "/home/vagrant/git/st2/virtualenv/lib/python2.7/site-packages/requests/models.py", line 928, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
HTTPError: 400 Client Error: Bad Request
MESSAGE: 59ee3b5a909a501d270e9057 is not an Inquiry. for url: http://127.0.0.1:9101/exp/inquiries/59ee3b5a909a501d270e9057
Inquiry "59ee3b5a909a501d270e9057" is not found.

humblearner avatar Oct 23 '17 19:10 humblearner

This issue seems to be resolved in st2 3.8.0. I'm no longer seeing a traceback with inquiry errors

[root@stackstorm ~]# st2 inquiry get abc123
Inquiry "abc123" is not found.

ERROR: Resource abc123 not found.

[root@stackstorm ~]# st2 inquiry list
+--------------------------+-------+-------+-------+------+
| id                       | roles | users | route | ttl  |
+--------------------------+-------+-------+-------+------+
| 645bb731d9db77d248fc81cd |       |       |       | 1440 |
+--------------------------+-------+-------+-------+------+
[root@stackstorm ~]# st2 inquiry respond -r '{"continue": true}' 645bb731d9db77d248fc81cd

Response accepted for inquiry 645bb731d9db77d248fc81cd.
[root@stackstorm ~]# st2 inquiry respond -r '{"continue": true}' 645bb731d9db77d248fc81cd
ERROR: Resource with id "645bb731d9db77d248fc81cd" doesn't exist.

jschoewe avatar May 10 '23 15:05 jschoewe