fix(ops_trace_manager): Adds app_id to TraceTask initialization (#20461)

Signed-off-by: -LAN- <laipz8200@outlook.com>
This commit is contained in:
-LAN- 2025-05-30 09:00:05 +08:00 committed by GitHub
parent 2ebf4e767b
commit f2e0d161a1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 0 deletions

View File

@ -32,6 +32,7 @@ from core.repositories import SQLAlchemyWorkflowNodeExecutionRepository
from core.workflow.nodes.enums import NodeType from core.workflow.nodes.enums import NodeType
from extensions.ext_database import db from extensions.ext_database import db
from models import Account, App, EndUser, WorkflowNodeExecutionTriggeredFrom from models import Account, App, EndUser, WorkflowNodeExecutionTriggeredFrom
from models.account import TenantAccountJoin
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@ -130,6 +131,12 @@ class LangFuseDataTrace(BaseTraceInstance):
service_account = session.query(Account).filter(Account.id == app.created_by).first() service_account = session.query(Account).filter(Account.id == app.created_by).first()
if not service_account: if not service_account:
raise ValueError(f"Creator account with id {app.created_by} not found for app {app_id}") raise ValueError(f"Creator account with id {app.created_by} not found for app {app_id}")
current_tenant = (
session.query(TenantAccountJoin).filter_by(account_id=service_account.id, current=True).first()
)
if not current_tenant:
raise ValueError(f"Current tenant not found for account {service_account.id}")
service_account.set_tenant_id(current_tenant.tenant_id)
workflow_node_execution_repository = SQLAlchemyWorkflowNodeExecutionRepository( workflow_node_execution_repository = SQLAlchemyWorkflowNodeExecutionRepository(
session_factory=session_factory, session_factory=session_factory,

View File

@ -487,6 +487,7 @@ class TraceTask:
"file_list": file_list, "file_list": file_list,
"triggered_from": workflow_run.triggered_from, "triggered_from": workflow_run.triggered_from,
"user_id": user_id, "user_id": user_id,
"app_id": workflow_run.app_id,
} }
workflow_trace_info = WorkflowTraceInfo( workflow_trace_info = WorkflowTraceInfo(