isamert / scli

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

json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 29792 column 25 (char 877052) #144

Closed 0mp closed 2 years ago

0mp commented 2 years ago

Hi, I think I hit a bug in how scli is parsing the JSON string from signal-cli:

$ scli
Traceback (most recent call last):
  File "/usr/local/share/scli/scli", line 4438, in <module>
    main()
  File "/usr/local/share/scli/scli", line 4423, in main
    coord = Coordinate()
  File "/usr/local/share/scli/scli", line 3789, in __init__
    self._chats_data = ChatsData(cfg.save_history)
  File "/usr/local/share/scli/scli", line 1618, in __init__
    self._load_history()
  File "/usr/local/share/scli/scli", line 1655, in _load_history
    history = json.load(history_file)
  File "/usr/local/lib/python3.8/json/__init__.py", line 293, in load
    return loads(fp.read(),
  File "/usr/local/lib/python3.8/json/__init__.py", line 357, in loads
    return _default_decoder.decode(s)
  File "/usr/local/lib/python3.8/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/local/lib/python3.8/json/decoder.py", line 353, in raw_decode
    obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 29792 column 25 (char 877052)

Versions I run:

Please let me know if there is anything I can do to help debugging this issue.

Cheers!

0mp commented 2 years ago

Hmm, so it turns out it is not really a bug in scli. My history file was corrupted. Here's the end of the file:

    {
      "source": "+123456789",
      "sourceName": "XYZ",
      "sourceDevice": 1,
      "timestamp": 1628935184419,
      "syncMessage": {
        "sentMessage": {

Once I removed this broken object and closed the "envelopes" array and the outermost object (i.e., ]}) scli started just fine.

I'm not sure if that's a bug. Sure, scli could suggest the user to look there but I'm not sure if that's a priority.

Cheers!

exquo commented 2 years ago

There are a few commits in master to address just this kind of problem (ref. https://github.com/isamert/scli/issues/112#issuecomment-927099678), but unfortunately they are not in a point release yet. I'll make a new release once everything is tested with the fresh signal-cli v0.9.1.


EDIT: sorry, missed your second message when writing this comment; so the stuff below you already knew:

Looks like the history file got corrupted :(. Could have been a result of an anomalous termination (e.g. receiving SIGKILL).

You can try editing the history file manually to make it a valid JSON file - to keep whatever has been saved during scli's last shutdown (the completeness is determined by luck). If you don't mind losing it, you can just delete the history file.