From bcaf88ae770fc7e1f22e7d5cdde2020d89b02cb4 Mon Sep 17 00:00:00 2001 From: meisnate12 Date: Fri, 19 Nov 2021 14:28:11 -0500 Subject: [PATCH] webhook response fix --- modules/webhooks.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/modules/webhooks.py b/modules/webhooks.py index a615a5c4..d0ef40b6 100644 --- a/modules/webhooks.py +++ b/modules/webhooks.py @@ -1,4 +1,5 @@ import logging +from json import JSONDecodeError from modules.util import Failed @@ -25,11 +26,15 @@ class Webhooks: response = self.config.get(url, json=json, params=params) else: response = self.config.post(webhook, json=json) - response_json = response.json() - if self.config.trace_mode: - logger.debug(f"Response: {response_json}") - if response.status_code >= 400 or ("result" in response_json and response_json["result"] == "error"): - raise Failed(f"({response.status_code} [{response.reason}]) {response_json}") + try: + response_json = response.json() + if self.config.trace_mode: + logger.debug(f"Response: {response_json}") + if response.status_code >= 400 or ("result" in response_json and response_json["result"] == "error"): + raise Failed(f"({response.status_code} [{response.reason}]) {response_json}") + except JSONDecodeError: + if response.status_code >= 400: + raise Failed(f"({response.status_code} [{response.reason}])") def start_time_hooks(self, start_time): if self.run_start_webhooks: