From 551a305fcfe1e07db72e4b3dfe544545aab37723 Mon Sep 17 00:00:00 2001 From: OG T Date: Sun, 22 Mar 2026 23:40:09 +0800 Subject: [PATCH] fix(config): rename _OPENCLAW_TG_USER_WHITELIST_RAW to comply with pydantic v2 Pydantic v2 does not allow field names with leading underscores. Changed from @property pattern to method pattern. Co-Authored-By: Claude Opus 4.5 --- apps/api/src/core/config.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/apps/api/src/core/config.py b/apps/api/src/core/config.py index e9446ae8..05fcfd51 100644 --- a/apps/api/src/core/config.py +++ b/apps/api/src/core/config.py @@ -225,17 +225,16 @@ class Settings(BaseSettings): default="", description="Telegram Chat ID for notifications", ) - # 使用 str 避免 pydantic-settings 自動 JSON 解析,在 property 中轉換 - _OPENCLAW_TG_USER_WHITELIST_RAW: str = Field( + # 使用 str 避免 pydantic-settings 自動 JSON 解析 + # Pydantic v2 禁止底線開頭的 Field 名稱 + OPENCLAW_TG_USER_WHITELIST: str = Field( default="", - alias="OPENCLAW_TG_USER_WHITELIST", - description="Telegram user IDs allowed to sign approvals (comma-separated)", + description="Telegram user IDs allowed to sign approvals (comma-separated or JSON array)", ) - @property - def OPENCLAW_TG_USER_WHITELIST(self) -> list[int]: - """Parse comma-separated user IDs to list[int]""" - raw = self._OPENCLAW_TG_USER_WHITELIST_RAW + def get_tg_user_whitelist(self) -> list[int]: + """Parse comma-separated or JSON array user IDs to list[int]""" + raw = self.OPENCLAW_TG_USER_WHITELIST if not raw or not raw.strip(): return [] # Handle JSON array format or comma-separated