fix: close platform-check silent-success loophole — raise WebsiteError on None list, missing account, or stale platform after update
This commit is contained in:
@@ -48,7 +48,7 @@ from app.schemas.website import (
|
||||
SyncUpstreamModelsResponse,
|
||||
)
|
||||
|
||||
from app.services.website_client import Sub2ApiWebsiteClient, _extract_id
|
||||
from app.services.website_client import Sub2ApiWebsiteClient, WebsiteError, _extract_id
|
||||
from app.services.website_sync import (
|
||||
binding_sources,
|
||||
sync_binding,
|
||||
@@ -1826,15 +1826,19 @@ def organize_website_groups(
|
||||
remote_acc["group_ids"] = new_group_ids
|
||||
if "platform" in update_payload:
|
||||
# 主动核对防线:防止子站忽略 platform 修改而发生静默失败
|
||||
fresh_accs = c.list_accounts() or []
|
||||
fresh_accs = c.list_accounts()
|
||||
if fresh_accs is None:
|
||||
raise WebsiteError("复查失败:拉取远端账号列表返回空,无法核对平台修改是否生效")
|
||||
fresh_acc = next((a for a in fresh_accs if str(c.extract_id(a)) == str(old_account_id)), None)
|
||||
if fresh_acc:
|
||||
remote_account_map[str(old_account_id)] = fresh_acc
|
||||
new_platform = fresh_acc.get("platform")
|
||||
if str(new_platform).lower() != str(platform).lower():
|
||||
raise WebsiteError(
|
||||
f"远端账号不支持修改平台属性,尝试将平台从 {remote_platform} 修改为 {platform} 失败"
|
||||
)
|
||||
if not fresh_acc:
|
||||
raise WebsiteError(f"复查失败:在远端账号列表中未找到要更新的账号 {old_account_id}")
|
||||
|
||||
remote_account_map[str(old_account_id)] = fresh_acc
|
||||
new_platform = fresh_acc.get("platform")
|
||||
if str(new_platform).lower() != str(platform).lower():
|
||||
raise WebsiteError(
|
||||
f"远端账号不支持修改平台属性,尝试将平台从 {remote_platform} 修改为 {platform} 失败"
|
||||
)
|
||||
remote_acc["platform"] = platform
|
||||
|
||||
msg_parts = []
|
||||
|
||||
Reference in New Issue
Block a user