ammen99 / github-irc-webhook

A simple python server to listen for Github webhooks and send IRC notifications
GNU General Public License v3.0
2 stars 3 forks source link

Exception on setup #1

Closed emersion closed 5 years ago

emersion commented 5 years ago

Not sure what happened. Seems to work properly after that.

127.0.0.1 - - [03/Mar/2019 09:44:20] "POST /github HTTP/1.1" 200 -
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 48000)
Traceback (most recent call last):
  File "/usr/lib/python3.7/socketserver.py", line 316, in _handle_request_noblock
    self.process_request(request, client_address)
  File "/usr/lib/python3.7/socketserver.py", line 347, in process_request
    self.finish_request(request, client_address)
  File "/usr/lib/python3.7/socketserver.py", line 360, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/lib/python3.7/socketserver.py", line 720, in __init__
    self.handle()
  File "/usr/lib/python3.7/http/server.py", line 426, in handle
    self.handle_one_request()
  File "/usr/lib/python3.7/http/server.py", line 414, in handle_one_request
    method()
  File "src/bot.py", line 36, in do_POST
    events.handle_event(irc, event_type, json.loads(data))
  File "/usr/lib/python3.7/json/__init__.py", line 348, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.7/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.7/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)
----------------------------------------
emersion commented 5 years ago

Maybe it was a HEAD request or something?

ammen99 commented 5 years ago

Such errors are caused by badly configured hook (wrong application type, should be application/json). Perhaps I should add error messages in this case.

emersion commented 5 years ago

We should probably check the Content-Type of the request, and print a better error message if it's not application/json.