Git-Auto-Deploy icon indicating copy to clipboard operation
Git-Auto-Deploy copied to clipboard

Error: No JSON object could be decoded

Open xAlstrat opened this issue 7 years ago • 3 comments

Hi. I couldn't fix this error, I think it is not a configuration problem, but I it can be.

I'm using GitAutoDeploy with Github. And after pushing I get this:

2017-07-20 22:27:59,871 [ERROR] self.handle() 2017-07-20 22:27:59,872 [ERROR] File "/usr/lib/python2.7/BaseHTTPServer.py", line 340, in handle 2017-07-20 22:27:59,875 [ERROR] self.handle_one_request() 2017-07-20 22:27:59,875 [ERROR] File "/usr/lib/python2.7/BaseHTTPServer.py", line 328, in handle_one_request 2017-07-20 22:27:59,875 [ERROR] method() 2017-07-20 22:27:59,875 [ERROR] File "/usr/lib/python2.7/dist-packages/gitautodeploy/httpserver.py", line 116, in do_POST 2017-07-20 22:27:59,876 [ERROR] 'payload': json.loads(request_body), 2017-07-20 22:27:59,876 [ERROR] File "/usr/lib/python2.7/json/init.py", line 339, in loads 2017-07-20 22:27:59,878 [ERROR] return _default_decoder.decode(s) 2017-07-20 22:27:59,878 [ERROR] File "/usr/lib/python2.7/json/decoder.py", line 364, in decode 2017-07-20 22:27:59,880 [ERROR] obj, end = self.raw_decode(s, idx=_w(s, 0).end()) 2017-07-20 22:27:59,880 [ERROR] File "/usr/lib/python2.7/json/decoder.py", line 382, in raw_decode 2017-07-20 22:27:59,880 [ERROR] raise ValueError("No JSON object could be decoded") 2017-07-20 22:27:59,880 [ERROR] ValueError: No JSON object could be decoded 2017-07-20 22:27:59,880 [INFO ] ---------------------------------------- 2017-07-20 22:27:59,881 [INFO ]

This is my configuration: https://gist.github.com/xAlstrat/a7cb2fad897259994f49d1cb1e580f0d

Do you know how to solve this problem? Thanks you so much !

xAlstrat avatar Jul 20 '17 23:07 xAlstrat

I solved it editing the httpserver. I had to preprocess the request_body to get a json object string.

... do_POST(self):
    ...
    import json, urllib, re # Urllib and re added
    ...
    action.log_info('Incoming request from %s:%s' % (self.client_address[0], self.client_address[1]))
    request_body = urllib.unquote(request_body).decode('utf8') # New line
    request_body = re.sub(r'^[^\{]+', '', request_body) # New line
    ...

xAlstrat avatar Jul 22 '17 05:07 xAlstrat

This solved my problem. This should be merged

marcotuna avatar Jan 30 '18 17:01 marcotuna

@xAlstrat Brilliant! Saved my day.

alexmzk avatar Feb 07 '19 12:02 alexmzk