From 402a187e826a842d117c199fba712815572d3d7c Mon Sep 17 00:00:00 2001 From: G30 <50341825+silentoplayz@users.noreply.github.com> Date: Mon, 21 Sep 2026 00:39:54 -0400 Subject: [PATCH] fix: return no chats when a folder search term matches no folder (#30273) --- backend/open_webui/models/chats.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/backend/open_webui/models/chats.py b/backend/open_webui/models/chats.py index 23b5276786..46131dc8e9 100644 --- a/backend/open_webui/models/chats.py +++ b/backend/open_webui/models/chats.py @@ -1988,10 +1988,8 @@ class ChatTable: ] # Extract folder names - folders = await Folders.search_folders_by_names( - user_id, - [word.replace('folder:', '') for word in search_text_words if word.startswith('folder:')], - ) + folder_names = [word.replace('folder:', '') for word in search_text_words if word.startswith('folder:')] + folders = await Folders.search_folders_by_names(user_id, folder_names) folder_ids = [folder.id for folder in folders] is_pinned = None @@ -2035,7 +2033,7 @@ class ChatTable: else: stmt = stmt.filter(Chat.share_id.is_(None)) - if folder_ids: + if folder_names: stmt = stmt.filter(Chat.folder_id.in_(folder_ids)) # Check if the database dialect is either 'sqlite' or 'postgresql'