nanos / FediFetcher

FediFetcher is a tool for Mastodon that automatically fetches missing replies and posts from other fediverse instances, and adds them to your own Mastodon instance.
https://blog.thms.uk/fedifetcher?utm_source=github
MIT License
318 stars 238 forks source link

Error decoding empty `recent_context` #155

Closed nohillside closed 3 months ago

nohillside commented 3 months ago

I'm running Fedifetcher in a Docker container. After a few days of running, it fails almost immediately after starting. The recent_context file itself is empty (length 0) at that point in time.

2024-08-05T11:41:08.170486503Z 2024-08-05 11:41:08 UTC: Starting FediFetcher
2024-08-05T11:41:08.304353199Z 2024-08-05 11:41:08 UTC: Job failed after 0:00:00.134115.
2024-08-05T11:41:08.305561647Z Traceback (most recent call last):
2024-08-05T11:41:08.305586847Z   File "/app/find_posts.py", line 1585, in <module>
2024-08-05T11:41:08.305842088Z     recently_checked_context = json.load(f)
2024-08-05T11:41:08.305854448Z                                ^^^^^^^^^^^^
2024-08-05T11:41:08.305857848Z   File "/usr/local/lib/python3.11/json/__init__.py", line 293, in load
2024-08-05T11:41:08.306184970Z     return loads(fp.read(),
2024-08-05T11:41:08.306251691Z            ^^^^^^^^^^^^^^^^
2024-08-05T11:41:08.306267811Z   File "/usr/local/lib/python3.11/json/__init__.py", line 346, in loads
2024-08-05T11:41:08.306271131Z     return _default_decoder.decode(s)
2024-08-05T11:41:08.306329651Z            ^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-08-05T11:41:08.306336291Z   File "/usr/local/lib/python3.11/json/decoder.py", line 337, in decode
2024-08-05T11:41:08.306339371Z     obj, end = self.raw_decode(s, idx=_w(s, 0).end())
2024-08-05T11:41:08.306342051Z                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-08-05T11:41:08.306344731Z   File "/usr/local/lib/python3.11/json/decoder.py", line 355, in raw_decode
2024-08-05T11:41:08.306508852Z     raise JSONDecodeError("Expecting value", s, err.value) from None
2024-08-05T11:41:08.306519252Z json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
nanos commented 3 months ago

Why would you have an empty file there? Did you place it yourself?

The file should either be non-existent (before first run) or have valid JSON content (e.g. an empty array [] if there are no recently checked contexts).

Are you able to remove the file?

nohillside commented 3 months ago

Sure, removing all the files allows fedifetcher to run again, didn't try with removing just recent_context.

As for why it's empty, I don't know. It's non-empty after a first successful run, there is nothing else accessing the directory, and there is enough free space on the disk.

Have increased the loglevel to DEBUG now, hopefully there will be an explanation why the file turns up empty all of a sudden. Will update once I have more information.

nanos commented 3 months ago

OK, I'll close this issue for now. Feel free to re-open if this happens again.