From 46f867cda6cd352f83e600e0b7c8032ff1395400 Mon Sep 17 00:00:00 2001 From: Classic298 <27028174+Classic298@users.noreply.github.com> Date: Wed, 31 Dec 2025 08:31:05 +0100 Subject: [PATCH] fix: prevent save_docs_to_vector_db crash on empty result.ids (#20275) Add check that result.ids exists and has length > 0 before accessing result.ids[0]. Prevents IndexError when query returns empty results. --- backend/open_webui/routers/retrieval.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/open_webui/routers/retrieval.py b/backend/open_webui/routers/retrieval.py index 1ad11cd15..b41815b2f 100644 --- a/backend/open_webui/routers/retrieval.py +++ b/backend/open_webui/routers/retrieval.py @@ -1308,7 +1308,7 @@ def save_docs_to_vector_db( filter={"hash": metadata["hash"]}, ) - if result is not None: + if result is not None and result.ids and len(result.ids) > 0: existing_doc_ids = result.ids[0] if existing_doc_ids: log.info(f"Document with hash {metadata['hash']} already exists")