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: allow API to access conversations created before upgrade to 1.10.0 (#28462)
张哲芳c2043d0f6de9
diff --git a/api/services/end_user_service.py b/api/services/end_user_service.pyindex aa4a2e46ecd..81098e95bb3 100644--- a/api/services/end_user_service.py+++ b/api/services/end_user_service.py@@ -1,11 +1,15 @@+import loggingfrom collections.abc import Mapping+from sqlalchemy import casefrom sqlalchemy.orm import Sessionfrom core.app.entities.app_invoke_entities import InvokeFromfrom extensions.ext_database import dbfrom models.model import App, DefaultEndUserSessionID, EndUser+logger = logging.getLogger(__name__)+class EndUserService:"""@@ -32,18 +36,36 @@ class EndUserService:user_id = DefaultEndUserSessionID.DEFAULT_SESSION_IDwith Session(db.engine, expire_on_commit=False) as session:+ # Query with ORDER BY to prioritize exact type matches while maintaining backward compatibility+ # This single query approach is more efficient than separate queriesend_user = (session.query(EndUser).where(EndUser.tenant_id == tenant_id,EndUser.app_id == app_id,EndUser.session_id == user_id,- EndUser.type == type,+ )+ .order_by(+ # Prioritize records with matching type (0 = match, 1 = no match)+ case((EndUser.type == type, 0), else_=1)).first())- if end_user is None:+ if end_user:+ # If found a legacy end user with different type, update it for future consistency+ if end_user.type != type:+ logger.info(+ "Upgrading legacy EndUser %s from type=%s to %s for session_id=%s",+ end_user.id,+ end_user.type,+ type,+ user_id,+ )+ end_user.type = type+ session.commit()+ else:+ # Create new end user if none existsend_user = EndUser(tenant_id=tenant_id,app_id=app_id,