sopel-irc / sopel

:robot::speech_balloon: An easy-to-use and highly extensible IRC Bot framework. Formerly Willie.
https://sopel.chat
Other
951 stars 403 forks source link

ERROR:sopel.modules.sopel.irc:Exception from $server: simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0) #1433

Closed traumschule closed 5 years ago

traumschule commented 5 years ago

Hi! I am running a torified version of sopel HEAD on our inspIRCd and get following error:

$ torsocks ./sopel.py
/home/user/sopel/sopel/loader.py:4: DeprecationWarning: the imp module is deprecated in favour of
 importlib; see the module's documentation for alternative uses                                                 
  import imp

Welcome to Sopel. Loading modules... 

1546456294 WARNING torsocks[15422]: [syscall] Unsupported syscall number 217. Denying the call (in tsocks_syscall() at syscall.c:568)
/home/user/sopel/sopel/tools/__init__.py:89: DeprecationWarning: Flags not at the start of the epression 'DrSopel[,:]\\s+(?i)(h' (truncated)
  return re.compile(pattern, flags)
/home/user/sopel/sopel/tools/__init__.py:89: DeprecationWarning: Flags not at the start of the epression 'DrSopel[,:]\\s+(?i)he' (truncated)
  return re.compile(pattern, flags)
Error loading weather: No module named 'xmltodict' (modules/weather.py:11)
Error loading xkcd: No module named 'xmltodict' (modules/search.py:11)
Error loading reddit: No module named 'praw' (modules/reddit.py:10)
Error loading ip: No module named 'geoip2' (modules/ip.py:13)
Error loading search: No module named 'xmltodict' (modules/search.py:11)
Error loading ipython: No module named 'IPython' (modules/ipython.py:24)
Error loading bugzilla: No module named 'xmltodict' (modules/bugzilla.py:12)

Registered 37 modules,
7 modules failed to load

Connecting to $v2.onion:6667...
Connected.
/usr/lib64/python3.6/socket.py:657: ResourceWarning: unclosed <socket.socket fd=4, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=6, laddr=('127.0.0.1', 51798), raddr=('104.31.65.169', 443)>
  self._sock = None
Traceback (most recent call last):
  File "/home/user/sopel/sopel/bot.py", line 478, in call
    exit_code = func(sopel, trigger)
  File "/home/user/sopel/sopel/modules/find_updates.py", line 36, in startup_version_check
    check_version(bot)
  File "/home/user/sopel/sopel/modules/find_updates.py", line 45, in check_version
    info = requests.get(version_url, verify=bot.config.core.verify_ssl).json()
  File "/usr/lib64/python3.6/site-packages/requests/models.py", line 892, in json
    return complexjson.loads(self.text, **kwargs)
  File "/usr/lib64/python3.6/site-packages/simplejson/__init__.py", line 518, in loads
    return _default_decoder.decode(s)
  File "/usr/lib64/python3.6/site-packages/simplejson/decoder.py", line 370, in decode
    obj, end = self.raw_decode(s)
  File "/usr/lib64/python3.6/site-packages/simplejson/decoder.py", line 400, in raw_decode
    return self.scan_once(s, idx=_w(s, idx).end())
simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

ERROR:sopel.modules.sopel.irc:Exception from $server: simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0) (file "/usr/lib64/python3.6/site-packages/simplejson/decoder.py", line 400, in
raw_decode) (:$server 251 :There are X users and X invisible on X servers)

It joined a channel, ping timeouted and rejoined, so it is working in principle but the error happens after every reconnect. The failing line is

check_version(bot)

$ ./sopel.py --version
/home/user/sopel/sopel/loader.py:4: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
  import imp
Sopel 6.5.3 (running on python 3.6.5)
https://sopel.chat/
kwaaak commented 5 years ago

Add exclude = find_updates to your config file (probably ~/.sopel/default.cfg)

traumschule commented 5 years ago

That helped, thanks! Fun fact: i can't reproduce it anymore now.

diff --git a/sopel/modules/find_updates.py b/sopel/modules/find_updates.py
index 300571d..f68feb2 100644
--- a/sopel/modules/find_updates.py
+++ b/sopel/modules/find_updates.py
@@ -38,7 +38,11 @@ def startup_version_check(bot, trigger):

 @sopel.module.interval(wait_time)
 def check_version(bot):
-    version = sopel.version_info
+    try
+        version = sopel.version_info
+    except Eception as e:
+        stderr('Error: check_version failed. Add this to the core section of
+~/.sopel/default.cfg:\nexclude = find_updates')
dgw commented 5 years ago

It seems the error has been worked around. Feel free to come back if the issue reoccurs!

For obvious reasons, bugs caused by changes made in a fork—such as "tor-ifying" the bot—can't be considered bugs in Sopel proper, so I'll close this. :smile_cat:

kwaaak commented 5 years ago

Most likely it was a connection problem to sopel.chat from one of the tor exit nodes

traumschule commented 5 years ago

Glad to be your first tor user, it's my first contact to sopel. Always confusing when typical issues are not caught properly and the log spits unclear error. See above patch as welcome present. :)