hatching / triage

Hatching Triage public command-line utility and API library.
BSD 3-Clause "New" or "Revised" License
65 stars 22 forks source link

Exception when listing profiles via CLI/Python SDK and list is empty #9

Closed goulou closed 2 years ago

goulou commented 2 years ago

The following exception occurs when trying to list profiles from a user with no profile.

$> triage list-profiles
Traceback (most recent call last):
  File "/home/user/venvs/hatching/bin/triage", line 8, in <module>
    sys.exit(cli())
  File "/home/user/venvs/hatching/lib/python3.9/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/home/user/venvs/hatching/lib/python3.9/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/home/user/venvs/hatching/lib/python3.9/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/user/venvs/hatching/lib/python3.9/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/user/venvs/hatching/lib/python3.9/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/home/user/venvs/hatching/lib/python3.9/site-packages/cli/triage.py", line 366, in list_profiles
    for i in c.profiles():
  File "/home/user/venvs/hatching/lib/python3.9/site-packages/triage/pagination.py", line 49, in __next__
    if not self._fetch_next_page():
  File "/home/user/venvs/hatching/lib/python3.9/site-packages/triage/pagination.py", line 40, in _fetch_next_page
    return len(resp['data']) > 0
TypeError: object of type 'NoneType' has no len()

Creating a profile removes the error, deleting it makes it reappear

(create a profile)
$> triage list-profiles
test
  timeout: 120
  network: internet
  tags: ['test']
  id: xxxxxxxxxx-xxxxx-xxxxx
triage delete-profile -p test
{}
$> triage list-profiles
Traceback (most recent call last):
(...)
TypeError: object of type 'NoneType' has no len()
RicoVZ commented 2 years ago

Thanks for reporting this @goulou. I've made some changes that should solve this.