From 1b1dc933fc3eadef2c9e6dac2e92f8fe5f611390 Mon Sep 17 00:00:00 2001 From: OpenCode Bot Date: Sun, 24 May 2026 22:42:55 +0800 Subject: [PATCH] fix: add error handling to load_config --- temp_file_trans_client/api.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/temp_file_trans_client/api.py b/temp_file_trans_client/api.py index ea36b87..9d7c7b1 100644 --- a/temp_file_trans_client/api.py +++ b/temp_file_trans_client/api.py @@ -7,8 +7,11 @@ CONFIG_PATH = os.path.join(os.path.dirname(__file__), 'config.json') def load_config(): if os.path.exists(CONFIG_PATH): - with open(CONFIG_PATH, 'r') as f: - return json.load(f) + try: + with open(CONFIG_PATH, 'r') as f: + return json.load(f) + except (json.JSONDecodeError, IOError): + return {"server_url": "http://localhost:5000", "default_expiry": "24h"} return {"server_url": "http://localhost:5000", "default_expiry": "24h"} def save_config(config):