StackStorm / StackStorm/st2

Minor: Cleaner response for already addressed inquiries

Open
#3,806 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
6.5k
Forks
787
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in st2client/commands/resource.py at get_resource_by_pk, then inspect st2client/models/core.py around get_by_id and handle_error. Reproduce the inquiry respond and inquiry get cases shown in the issue. Done means these already-addressed or missing inquiries show the concise ERROR and MESSAGE output without the traceback or duplicate not-found line.

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
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.