From 6c0eb7f941c13b750f7bf1bd109565e9361f7a24 Mon Sep 17 00:00:00 2001 From: agatha Date: Sat, 7 Sep 2024 17:09:32 -0400 Subject: [PATCH] fix: handle uncaught UnicodeDecodeError UnicodeDecodeError occurred when trying to connect to the server with HTTPS. The error was not caught by the broad Exception clause in `handle_agent`, causing a traceback to be dumped. --- server/src/main.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/server/src/main.py b/server/src/main.py index 2d3c36d..053cd4c 100644 --- a/server/src/main.py +++ b/server/src/main.py @@ -87,6 +87,8 @@ class Server: conn.send(json.dumps({"command": command}).encode()) except json.decoder.JSONDecodeError: logger.error(f"Invalid JSON received from {addr}") + except UnicodeDecodeError: + logger.error(f"Invalid UTF-8 received from {addr}") except Exception as e: logger.error(f"Error handling agent {agent_id}: {e}") finally: