From 3de4e2369bc6b3d52f4f4dc682624d0259b2193c Mon Sep 17 00:00:00 2001 From: IITII Date: Tue, 19 May 2026 02:40:57 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E5=8A=A0=E8=BD=BD=E5=A4=B1=E8=B4=A5=E7=9A=84=E6=97=B6=E5=80=99?= =?UTF-8?q?=E8=BE=93=E5=87=BA=E8=AF=A6=E6=83=85=20#8204?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 某些情况下重启 AstrBot 后, 文件 /AstrBot/data/cmd_config.json 可能为空 --- astrbot/core/config/astrbot_config.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/astrbot/core/config/astrbot_config.py b/astrbot/core/config/astrbot_config.py index 4d62becb55..5f4e19e40f 100644 --- a/astrbot/core/config/astrbot_config.py +++ b/astrbot/core/config/astrbot_config.py @@ -62,7 +62,13 @@ def __init__( # Handle UTF-8 BOM if present if conf_str.startswith("\ufeff"): conf_str = conf_str[1:] - conf = json.loads(conf_str) + if not conf_str: + raise EnvironmentError(f'文件 {config_path} 为空, 请手动处理...') + try: + conf = json.loads(conf_str) + except Exception as e: + logger.error(f'读取文件失败 {config_path}: {e}') + raise e dashboard_conf = conf.get("dashboard") legacy_dashboard_password_change_required = bool( isinstance(dashboard_conf, dict)