YoloSwagTeam / t2m

Twitter to Mastodon timeline forwarding tool
GNU General Public License v3.0
76 stars 15 forks source link

JSONDecodeError: Expecting value #12

Open Zanonia opened 6 years ago

Zanonia commented 6 years ago

Hello

I have this error since today, whereas the script had been running without problems for months and nothing has changed on my system :

Traceback (most recent call last):
  File "./t2m", line 267, in <module>
    parser.dispatch()
  File "/root/.t2m/.t2m/lib/python3.5/site-packages/argh/helpers.py", line 55, in dispatch
    return dispatch(self, *args, **kwargs)
  File "/root/.t2m/.t2m/lib/python3.5/site-packages/argh/dispatching.py", line 174, in dispatch
    for line in lines:
  File "/root/.t2m/.t2m/lib/python3.5/site-packages/argh/dispatching.py", line 277, in _execute_command
    for line in result:
  File "/root/.t2m/.t2m/lib/python3.5/site-packages/argh/dispatching.py", line 260, in _call
    result = function(*positional, **keywords)
  File "./t2m", line 178, in one
    db = get_db()
  File "./t2m", line 34, in get_db
    return json.load(open("db.json", "r"))
  File "/usr/lib/python3.5/json/__init__.py", line 268, in load
    parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
  File "/usr/lib/python3.5/json/__init__.py", line 319, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.5/json/decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.5/json/decoder.py", line 357, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 259 column 3 (char 8213)

Edit : Apparently, the problem was due to poor data formatting in db.json. I don't understand how this happened. I solved the problem by rewriting a new db.json manually.

Psycojoker commented 6 years ago

Hello,

That's weird, have you edited db.json by hand? I can't see any other situation where that could happen (or that would be a serious bug in the json python stl which I can't expect to happen for those kind of simple situations)

Zanonia commented 6 years ago

I didn't touch the db.json until t2m crashed. I kept a copy of the original, I think the problem is the comma on line 259:

            865219095100313600,
            865303903293906944,
            865457539185483776,
            865468081333616640,
            865472026546364418,
            86548177475470,
  ,
            865488515278163969,
            865565397780754434,
            865582743744385024,

Can a large number of tweets to be transferred and a too frequent call of the script (the cron was on a 2min interval at this time) cause this kind of problems?

I also noticed in Nginx's error log that when the media attached to a tweet exceeded the size limit of the instance (1MB on mine), an upload was attempted every time you use t2m and this for several days. I don't know if that deserves to open a new issue.