From 201c38a08aa69a4aaccd3f53a967264542138170 Mon Sep 17 00:00:00 2001 From: Classic298 <27028174+Classic298@users.noreply.github.com> Date: Wed, 31 Dec 2025 08:31:26 +0100 Subject: [PATCH] fix: prevent delete_entries_from_collection crash when file is None (#20274) Add null check after Files.get_file_by_id() before accessing file.hash. Raises HTTP 404 instead of crashing with AttributeError when file doesn't exist. --- backend/open_webui/routers/retrieval.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/backend/open_webui/routers/retrieval.py b/backend/open_webui/routers/retrieval.py index b41815b2f..2fc7ca2ef 100644 --- a/backend/open_webui/routers/retrieval.py +++ b/backend/open_webui/routers/retrieval.py @@ -2421,6 +2421,11 @@ def delete_entries_from_collection( try: if VECTOR_DB_CLIENT.has_collection(collection_name=form_data.collection_name): file = Files.get_file_by_id(form_data.file_id, db=db) + if not file: + raise HTTPException( + status_code=status.HTTP_404_NOT_FOUND, + detail=ERROR_MESSAGES.NOT_FOUND, + ) hash = file.hash VECTOR_DB_CLIENT.delete(