fix: 优化上游模型同步的写回逻辑,采用增量 JSONB merge,避免脱敏的 credentials 覆盖或丢失原有敏感字段
This commit is contained in:
@@ -1393,13 +1393,8 @@ def sync_website_accounts_upstream_models(
|
||||
# 构造 model_mapping
|
||||
model_mapping = {m: m for m in valid_models}
|
||||
|
||||
# 优先读取账号现有的 credentials 并 merge,以防覆盖掉 api_key/base_url 等其他配置
|
||||
current_creds = remote_acc.get("credentials") or {}
|
||||
updated_creds = dict(current_creds)
|
||||
updated_creds["model_mapping"] = model_mapping
|
||||
|
||||
# 调用更新接口
|
||||
c.update_account(aid, {"credentials": updated_creds})
|
||||
# 直接发送增量字段进行更新,依赖远端的 JSONB merge 逻辑,避免覆盖/丢失敏感 credentials
|
||||
c.update_account(aid, {"credentials": {"model_mapping": model_mapping}})
|
||||
|
||||
items.append(SyncUpstreamModelsItem(
|
||||
account_id=aid,
|
||||
|
||||
Reference in New Issue
Block a user