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 <noreply@anthropic.com>
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user