Git-Auto-Deploy
Git-Auto-Deploy copied to clipboard
Error: No JSON object could be decoded
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 !
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
...
This solved my problem. This should be merged
@xAlstrat Brilliant! Saved my day.