From 16e78271340237f6207649f3f058fe025622b621 Mon Sep 17 00:00:00 2001 From: Algorithm5838 <108630393+Algorithm5838@users.noreply.github.com> Date: Mon, 1 Jun 2026 19:25:35 +0300 Subject: [PATCH] fix: use db instead of undefined session in chats model (#25455) --- backend/open_webui/models/chats.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/backend/open_webui/models/chats.py b/backend/open_webui/models/chats.py index 63a8bb1f2e..1ad6959e5c 100644 --- a/backend/open_webui/models/chats.py +++ b/backend/open_webui/models/chats.py @@ -696,7 +696,7 @@ class ChatTable: from open_webui.models.shared_chats import SharedChats try: - return await SharedChats.delete_by_chat_id(chat_id, db=session) + return await SharedChats.delete_by_chat_id(chat_id, db=db) except Exception: return False @@ -820,7 +820,7 @@ class ChatTable: """Delegate to SharedChats for listing shared chats by user.""" from open_webui.models.shared_chats import SharedChats - return await SharedChats.get_by_user_id(user_id, filter=filter, skip=skip, limit=limit, db=session) + return await SharedChats.get_by_user_id(user_id, filter=filter, skip=skip, limit=limit, db=db) async def get_chat_list_by_user_id( self, @@ -960,7 +960,7 @@ class ChatTable: from open_webui.models.shared_chats import SharedChats try: - shared = await SharedChats.get_by_id(id, db=session) + shared = await SharedChats.get_by_id(id, db=db) if shared: # Return a ChatModel-compatible view of the snapshot return ChatModel( @@ -1422,7 +1422,7 @@ class ChatTable: self, id: str, user_id: str, tag_name: str, db: AsyncSession | None = None ) -> ChatModel | None: tag_id = tag_name.replace(' ', '_').lower() - await Tags.ensure_tags_exist([tag_name], user_id, db=session) + await Tags.ensure_tags_exist([tag_name], user_id, db=db) try: async with get_async_db_context(db) as session: chat = await session.get(Chat, id)