Skip to content

Show pretty error message to a user when operation-like cli command fails because of wrong password

Mateusz Żebrak requested to merge mzebrak/cli-invalid-password-error into develop

FYI: @agrabowska

Previously user had to see full stack trace like:

│ /clive/clive/__private/core/commands/activate.py:38 in _execute                                  │
│                                                                                                  │
│   35 │   │   │   │   arg = arg_raw["error"]["message"] if isinstance(arg_raw, dict) else arg_    │
│   36 │   │   │   │   if WalletDoesNotExistsError.ERROR_MESSAGE in arg:                           │
│   37 │   │   │   │   │   raise WalletDoesNotExistsError(error) from error                        │
│ ❱ 38 │   │   │   raise CannotActivateError(error) from error                                     │
│   39 │   │                                                                                       │
│   40 │   │   self.app_state.activate()                                                           │
│   41                                                                                             │
│                                                                                                  │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │     arg = 'Problem occurred during communication with: url=http://0.0.0.0:43265,             │ │
│ │           request={"'+998                                                                    │ │
│ │ arg_raw = 'Problem occurred during communication with: url=http://0.0.0.0:43265,             │ │
│ │           request={"'+998                                                                    │ │
│ │    self = Activate(                                                                          │ │
│ │           │   password='mypassword',                                                         │ │
│ │           │   app_state=AppState(                                                            │ │
│ │           │   │   world=<clive.__private.core.world.TyperWorld object at 0x7fba77f74d30>,    │ │
│ │           │   │   _is_active=False,                                                          │ │
│ │           │   │   _dynamic_global_properties=None                                            │ │
│ │           │   ),                                                                             │ │
│ │           │   beekeeper=<clive.__private.core.beekeeper.handle.Beekeeper object at           │ │
│ │           0x7fba77f75e70>,                                                                   │ │
│ │           │   wallet='alice',                                                                │ │
│ │           │   time=None                                                                      │ │
│ │           )                                                                                  │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
CannotActivateError: Problem occurred during communication with: url=http://0.0.0.0:43265, request={"id": 0, "jsonrpc": "2.0",
"method": "beekeeper_api.unlock", "params": {"wallet_name": "alice", "password": "mypassword", "token":
"8b7a176e6988d98019d7fa45fa14526794a15028ccfab03800fa9d0f9a7cbd4e"}}, result={'jsonrpc': '2.0', 'error': {'code': -32000, 'message':
'AES error:error during aes 256 cbc decrypt final', 'data': {'code': 18, 'name': 'aes_exception', 'message': 'AES error', 'stack':
[{'context': {'level': 'error', 'file': 'aes.cpp', 'line': 267, 'method': 'aes_decrypt', 'hostname': '', 'timestamp':
'2023-09-14T12:30:56'}, 'format': 'error during aes 256 cbc decrypt final', 'data': {'s': 'error:1C800064:Provider routines::bad
decrypt'}}, {'context': {'level': 'warn', 'file': 'beekeeper_wallet.cpp', 'line': 352, 'method': 'unlock', 'hostname': '',
'timestamp': '2023-09-14T12:30:56'}, 'format': '', 'data': {'"Invalid password for wallet: "': 'Invalid password for wallet: ',
'get_wallet_filename()': '/home/hived_admin/.clive/beekeeper/alice.wallet'}}], 'extension': {}}}, 'id': 0}
Edited by Mateusz Żebrak

Merge request reports