mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-05 18:38:17 -05:00
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 <noreply@anthropic.com>
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user