From 5796d4436348264cae535a3a0d308acfbbe260c4 Mon Sep 17 00:00:00 2001 From: Classic298 <27028174+Classic298@users.noreply.github.com> Date: Mon, 29 Jun 2026 10:21:09 +0200 Subject: [PATCH] fix: defer missing-local-embedding error so it can't crash boot (#25683) get_embedding_function runs at import time (main.py), so the empty-engine + no-model guard added in 55ca719b raised ValueError during startup and bricked the instance: a blank embedding model set via the UI made the app unbootable, with no way back into settings to undo it. Move the check into the returned coroutine so construction always succeeds and the error only fires when something actually embeds, surfacing as a clear request error instead of the old cryptic 'NoneType has no attribute encode'. Fixes #25634 Fixes #25165 Co-authored-by: Claude Opus 4.8 (1M context) --- backend/open_webui/retrieval/utils.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/backend/open_webui/retrieval/utils.py b/backend/open_webui/retrieval/utils.py index 0421787819..5ba010c445 100644 --- a/backend/open_webui/retrieval/utils.py +++ b/backend/open_webui/retrieval/utils.py @@ -1089,15 +1089,15 @@ def get_embedding_function( concurrent_requests=0, ) -> Awaitable: if embedding_engine == '': - if embedding_function is None: - raise ValueError( - 'No embedding model is loaded. Set RAG_EMBEDDING_MODEL to a valid ' - 'SentenceTransformer model name, or configure an external ' - 'RAG_EMBEDDING_ENGINE (ollama, openai, azure_openai).' - ) - # Sentence transformers: CPU-bound sync operation async def async_embedding_function(query, prefix=None, user=None): + # Deferred so a missing local model degrades RAG instead of crashing boot. + if embedding_function is None: + raise ValueError( + 'No embedding model is loaded. Set RAG_EMBEDDING_MODEL to a valid ' + 'SentenceTransformer model name, or configure an external ' + 'RAG_EMBEDDING_ENGINE (ollama, openai, azure_openai).' + ) return await asyncio.to_thread( ( lambda query, prefix=None: embedding_function.encode(