From 656de56a3ef9113c42f37aa527d4c01cc964eb92 Mon Sep 17 00:00:00 2001 From: Classic298 <27028174+Classic298@users.noreply.github.com> Date: Mon, 16 Feb 2026 20:02:54 +0100 Subject: [PATCH] fix: gracefully handle missing functions when loading models (#21476) When models reference functions (via filterIds/actionIds) that no longer exist in the database, the /api/models endpoint crashes with a 500 error, preventing the UI from loading chats entirely. This can happen after upgrades when built-in functions are removed or when user-created functions are deleted while still referenced by models. Instead of raising an exception, log at INFO level and skip the missing function so the rest of the models load successfully. Fixes #21464 https://claude.ai/code/session_015JRM7m2bNeZPBBmV2Gv4Mj Co-authored-by: Claude --- backend/open_webui/utils/models.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/backend/open_webui/utils/models.py b/backend/open_webui/utils/models.py index 86ba292c51..bd72639c77 100644 --- a/backend/open_webui/utils/models.py +++ b/backend/open_webui/utils/models.py @@ -320,9 +320,13 @@ async def get_all_models(request, refresh: bool = False, user: UserModel = None) for action_id in action_ids: action_function = functions_by_id.get(action_id) if action_function is None: - raise Exception(f"Action not found: {action_id}") + log.info(f"Action not found: {action_id}") + continue function_module = request.app.state.FUNCTIONS.get(action_id) + if function_module is None: + log.info(f"Failed to load action module: {action_id}") + continue model["actions"].extend( get_action_items_from_module(action_function, function_module) ) @@ -331,10 +335,13 @@ async def get_all_models(request, refresh: bool = False, user: UserModel = None) for filter_id in filter_ids: filter_function = functions_by_id.get(filter_id) if filter_function is None: - raise Exception(f"Filter not found: {filter_id}") - + log.info(f"Filter not found: {filter_id}") + continue + function_module = request.app.state.FUNCTIONS.get(filter_id) - + if function_module is None: + log.info(f"Failed to load filter module: {filter_id}") + continue if getattr(function_module, "toggle", None): model["filters"].extend( get_filter_items_from_module(filter_function, function_module)