isamert / scli

a simple terminal user interface for signal messenger (using signal-cli)
GNU General Public License v3.0
449 stars 39 forks source link

scli crashes due to "IndexError: list index out of range" #127

Closed 0mp closed 3 years ago

0mp commented 3 years ago

I'm not sure why scli crashed, it was just idling there in a terminal window for a few seconds and then I saw the trace. I started scli again after that and it just worked as expected.

Let me know if I can test out any patches.

$ scli
Traceback (most recent call last):
  File "/usr/local/bin/scli", line 4392, in <module>
    main()
  File "/usr/local/bin/scli", line 4386, in main
    loop.run()
  File "/usr/local/lib/python3.8/site-packages/urwid/main_loop.py", line 287, in run
    self._run()
  File "/usr/local/lib/python3.8/site-packages/urwid/main_loop.py", line 385, in _run
    self.event_loop.run()
  File "/usr/local/lib/python3.8/site-packages/urwid/main_loop.py", line 790, in run
    self._loop()
  File "/usr/local/lib/python3.8/site-packages/urwid/main_loop.py", line 827, in _loop
    self._watch_files[fd]()
  File "/usr/local/lib/python3.8/site-packages/urwid/main_loop.py", line 233, in cb
    rval = callback(data)
  File "/usr/local/bin/scli", line 648, in _daemon_stdout_handler
    self._envelope_handler(envelope)
  File "/usr/local/bin/scli", line 676, in _envelope_handler
    self.callbacks['receive_reaction'](envelope)
  File "/usr/local/bin/scli", line 3858, in _on_receive_reaction
    msg = self._chats_data.chats.add_reaction_envelope(envelope)
  File "/usr/local/bin/scli", line 1295, in add_reaction_envelope
    msg = self.get_msg_for_timestamp(
  File "/usr/local/bin/scli", line 1284, in get_msg_for_timestamp
    return chat.get_msg_for_timestamp(timestamp, sender_num)
  File "/usr/local/bin/scli", line 1225, in get_msg_for_timestamp
    ind = self.index_ts(timestamp, sender_num)
  File "/usr/local/bin/scli", line 1207, in index_ts
    msg = self[-1]
IndexError: list index out of range

Thanks!

exquo commented 3 years ago

Looks like scli has received a reaction to an older message, while the corresponding chat's history was empty. (This can happen if scli is restarted between receiving the original message and the reaction, and --save-history is not used).

This shouldn't result in a crash, so that's a bug. Will fix soon. Thanks for reporting!