Skip to content

Receptor prints Python tracebacks when it ought to print human-friendly error messages #219

@elyezer

Description

@elyezer

In general, receptor prints raw stacktraces when it finds an error while running the CLI. Considering receptor status as an example here.

Help message of receptor status does not show any required argument:

$ poetry run receptor status --help
usage: receptor status [-h] [--peer STATUS_PEER]
                       [--ws_extra_header STATUS_WS_EXTRA_HEADERS]
                       [--show-ephemeral] [--ws_heartbeat STATUS_WS_HEARTBEAT]

optional arguments:
  -h, --help            show this help message and exit
  --peer STATUS_PEER    The peer to access the mesh through. If unspecified
                        here or in a config file, localhost:8888 will be used.
  --ws_extra_header STATUS_WS_EXTRA_HEADERS
                        Set additional headers to provide when connecting to
                        websocket peers.
  --show-ephemeral      Show ephemeral nodes in output
  --ws_heartbeat STATUS_WS_HEARTBEAT
                        Set heartbeat interval for websocket connection

But when we try to run it without any option it raises the following:

$ poetry run receptor status
ERROR 2020-05-05 13:35:35,710  __main__ main: an error occured while running receptor
Traceback (most recent call last):
  File "/home/elyezer/code/receptor/receptor/receptor/entrypoints.py", line 210, in run_as_status
    controller = Controller(config)
  File "/home/elyezer/code/receptor/receptor/receptor/controller.py", line 34, in __init__
    self.receptor = Receptor(config)
  File "/home/elyezer/code/receptor/receptor/receptor/receptor.py", line 94, in __init__
    os.makedirs(os.path.join(self.config.default_data_dir, self.node_id))
  File "/usr/lib64/python3.7/os.py", line 213, in makedirs
    makedirs(head, exist_ok=exist_ok)
  File "/usr/lib64/python3.7/os.py", line 223, in makedirs
    mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: '/var/lib/receptor'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/elyezer/code/receptor/receptor/receptor/__main__.py", line 59, in main
    config.go()
  File "/home/elyezer/code/receptor/receptor/receptor/config.py", line 570, in go
    self._parsed_args.func(self)
  File "/home/elyezer/code/receptor/receptor/receptor/entrypoints.py", line 213, in run_as_status
    controller.cleanup_tmpdir()
UnboundLocalError: local variable 'controller' referenced before assignment

It is expected that the status would just work when run without any option by either just working or providing a meaningful message why it was not able to run.

In the above example I had nodes running on ports 9999 and 9998, that said it probably failed because it tried to connect to the default localhost:8888 but hasn't found anything running there.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions