From 16c492ef0af5880ee1c41c4bc9de3e8d22aaed63 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Mon, 8 Oct 2018 16:30:51 +0200 Subject: [PATCH] [FIX] runbot_merge: merge() can be non-json in some cases (???) Rather than blow up with a json error and take down the cron, convert json decode error to a mergeerror in order to put the PR in error and try to dump however much data we can. --- runbot_merge/github.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/runbot_merge/github.py b/runbot_merge/github.py index fe8ec00b..c6702656 100644 --- a/runbot_merge/github.py +++ b/runbot_merge/github.py @@ -114,7 +114,10 @@ class GH(object): 'head': sha, 'commit_message': message, }, check={409: exceptions.MergeError}) - r = r.json() + try: + r = r.json() + except Exception: + raise exceptions.MergeError("Got non-JSON reponse from github: %s %s (%s)" % (r.status_code, r.reason, r.content.decode('iso-8859-1'))) _logger.debug("merge(%s, %s, %s) -> %s", self._repo, dest, shorten(message), r['sha']) return dict(r['commit'], sha=r['sha'])