navbot crashes when an issue number is posted to the channel
Description
Not sure when this started, but here is the traceback from the logs:
2022-07-26 09:09:42,218 [INFO] [navbot] Fetching data for issue request by Lunkwill
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/requests/models.py", line 910, in json
return complexjson.loads(self.text, **kwargs)
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 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/bin/navbot.py", line 147, in <module>
main()
File "/usr/local/bin/navbot.py", line 39, in main
bot.start()
File "/usr/local/lib/python3.8/site-packages/irc/bot.py", line 346, in start
super().start()
File "/usr/local/lib/python3.8/site-packages/irc/client.py", line 1202, in start
self.reactor.process_forever()
File "/usr/local/lib/python3.8/site-packages/irc/client.py", line 846, in process_forever
consume(repeatfunc(one))
File "/usr/local/lib/python3.8/site-packages/more_itertools/recipes.py", line 142, in consume
deque(iterator, maxlen=0)
File "/usr/local/lib/python3.8/site-packages/irc/client.py", line 827, in process_once
self.process_data(in_)
File "/usr/local/lib/python3.8/site-packages/irc/client.py", line 792, in process_data
conn.process_data()
File "/usr/local/lib/python3.8/site-packages/irc/client.py", line 268, in process_data
self._process_line(line)
File "/usr/local/lib/python3.8/site-packages/irc/client.py", line 299, in _process_line
handler(arguments, command, source, tags)
File "/usr/local/lib/python3.8/site-packages/irc/client.py", line 343, in _handle_message
self._handle_event(event)
File "/usr/local/lib/python3.8/site-packages/irc/client.py", line 376, in _handle_event
self.reactor._handle_event(self, event)
File "/usr/local/lib/python3.8/site-packages/irc/client.py", line 922, in _handle_event
result = handler.callback(connection, event)
File "/usr/local/lib/python3.8/site-packages/irc/client.py", line 1159, in _dispatcher
method(connection, event)
File "/usr/local/bin/navbot.py", line 51, in on_pubmsg
self.on_issuemsg(connection, nick, message, event.target)
File "/usr/local/bin/navbot.py", line 61, in on_issuemsg
url, issue_data = get_issue_data(issue_id)
File "/usr/local/bin/navbot.py", line 72, in get_issue_data
return url, response.json()
File "/usr/local/lib/python3.8/site-packages/requests/models.py", line 917, in json
raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: [Errno Expecting value] : 0
Expected behavior
-
navbot should be fault-tolerant (i.e. not crash entirely thanks to such unhandled errors) -
navbot should still be able to fetch the github issue title/url and post it.