Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
fix Version 2.0.0-beta.2: Chat annotations Api Error #25506 (#27206)
Cursx87fb9a6b6985
diff --git a/api/controllers/service_api/wraps.py b/api/controllers/service_api/wraps.pyindex fe1e2c419b6..319b7bd7809 100644--- a/api/controllers/service_api/wraps.py+++ b/api/controllers/service_api/wraps.py@@ -67,6 +67,7 @@ def validate_app_token(view: Callable[P, R] | None = None, *, fetch_user_arg: Fekwargs["app_model"] = app_model+ # If caller needs end-user context, attach EndUser to current_userif fetch_user_arg:if fetch_user_arg.fetch_from == WhereisUserArg.QUERY:user_id = request.args.get("user")@@ -75,7 +76,6 @@ def validate_app_token(view: Callable[P, R] | None = None, *, fetch_user_arg: Feelif fetch_user_arg.fetch_from == WhereisUserArg.FORM:user_id = request.form.get("user")else:- # use default-useruser_id = Noneif not user_id and fetch_user_arg.required:@@ -90,6 +90,28 @@ def validate_app_token(view: Callable[P, R] | None = None, *, fetch_user_arg: Fe# Set EndUser as current logged-in user for flask_login.current_usercurrent_app.login_manager._update_request_context_with_user(end_user) # type: ignoreuser_logged_in.send(current_app._get_current_object(), user=end_user) # type: ignore+ else:+ # For service API without end-user context, ensure an Account is logged in+ # so services relying on current_account_with_tenant() work correctly.+ tenant_owner_info = (+ db.session.query(Tenant, Account)+ .join(TenantAccountJoin, Tenant.id == TenantAccountJoin.tenant_id)+ .join(Account, TenantAccountJoin.account_id == Account.id)+ .where(+ Tenant.id == app_model.tenant_id,+ TenantAccountJoin.role == "owner",+ Tenant.status == TenantStatus.NORMAL,+ )+ .one_or_none()+ )++ if tenant_owner_info:+ tenant_model, account = tenant_owner_info+ account.current_tenant = tenant_model+ current_app.login_manager._update_request_context_with_user(account) # type: ignore+ user_logged_in.send(current_app._get_current_object(), user=current_user) # type: ignore+ else:+ raise Unauthorized("Tenant owner account not found or tenant is not active.")return view_func(*args, **kwargs)