From d337f663d960c3a33d0d2d8acb63531adb1729e4 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Fri, 19 Jan 2024 21:10:11 +0000 Subject: [PATCH] Handle json decode error --- daemon.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/daemon.py b/daemon.py index 927fda2d5..7e16a23d2 100644 --- a/daemon.py +++ b/daemon.py @@ -24212,7 +24212,14 @@ class PubServer(BaseHTTPRequestHandler): return # convert the raw bytes to json - message_json = json.loads(message_bytes) + try: + message_json = json.loads(message_bytes) + except json.decoder.JSONDecodeError as ex: + self._400() + print('EX: json decode error ' + str(ex) + + ' from POST ' + str(message_bytes)) + self.server.postreq_busy = False + return fitness_performance(postreq_start_time, self.server.fitness, '_POST', 'load json',