From eaa66ba71aad5a26ee0929e582468105c55eabae Mon Sep 17 00:00:00 2001 From: wwq Date: Thu, 23 Apr 2026 00:14:29 +0800 Subject: [PATCH] fix(quota_manager): retrieve workspace_id from api_key_auth context - Add logic to resolve the workspace ID derived from the API key authentication context. --- api/app/core/quota_manager.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/api/app/core/quota_manager.py b/api/app/core/quota_manager.py index 6f1be886..d59c42e0 100644 --- a/api/app/core/quota_manager.py +++ b/api/app/core/quota_manager.py @@ -37,6 +37,11 @@ def _get_workspace_id_from_kwargs(kwargs: dict): if workspace_id: return workspace_id + # 从 api_key_auth.workspace_id 获取(API Key 认证场景) + api_key_auth = kwargs.get("api_key_auth") + if api_key_auth and hasattr(api_key_auth, 'workspace_id'): + return api_key_auth.workspace_id + # 从 user.current_workspace_id 获取 user = _get_user_from_kwargs(kwargs) if user: