Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions server/app/domains/model_provider/service/provider_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,18 @@ def update(provider_id: int, user_id: int, data: dict) -> dict:
).first()
if not model:
return {"success": False, "error_code": "PROVIDER_NOT_FOUND"}
# H10: only allow updating safe fields
_UPDATABLE_FIELDS = {"provider_name", "api_key", "api_base", "extra_config", "prefer", "is_vaild"}
# H10: only allow updating safe fields. Field names must match the
# `Provider` ORM model (and `ProviderIn` request schema) verbatim —
# `setattr(model, key, value)` silently no-ops on a missing field.
_UPDATABLE_FIELDS = {
"provider_name",
"api_key",
"model_type",
"endpoint_url",
"encrypted_config",
"prefer",
"is_vaild",
}
for key, value in data.items():
if key in _UPDATABLE_FIELDS:
setattr(model, key, value)
Expand Down