Update api/services/tools/builtin_tools_manage_service.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
Xiyuan Chen 2026-02-04 17:57:23 -08:00 committed by NFish
parent b921711e9e
commit d7c3ae50dc
1 changed files with 5 additions and 1 deletions

View File

@ -424,7 +424,11 @@ class BuiltinToolManageService:
# Enterprise: verify admin permission for tenant-wide operation
from models.account import TenantAccountRole
if account and not TenantAccountRole.is_privileged_role(account.current_role):
if account is None:
# In enterprise mode, an account context is required to perform permission checks
raise ValueError("Account is required to set default credentials in enterprise mode")
if not TenantAccountRole.is_privileged_role(account.current_role):
raise ValueError("Only workspace admins/owners can set default credentials in enterprise mode")
# Enterprise: clear ALL defaults for this provider in the tenant
# (regardless of user_id, since enterprise credentials may have different user_id)