From f89c4a4318b8cddffdc39e061e15c4e6b73ee5fb Mon Sep 17 00:00:00 2001 From: Classic298 <27028174+Classic298@users.noreply.github.com> Date: Thu, 4 Jun 2026 01:16:59 +0200 Subject: [PATCH] fix: defer missing-local-embedding error so it can't crash boot 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'. Co-Authored-By: Claude Opus 4.8 (1M context) Fixes #25634 Fixes #25165 --- 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 2db9f47c53..ab97821423 100644 --- a/backend/open_webui/retrieval/utils.py +++ b/backend/open_webui/retrieval/utils.py @@ -927,15 +927,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(