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