From 29719c8bfb79a7d81471528c1cf0e863dc7f22bc Mon Sep 17 00:00:00 2001 From: Classic298 <27028174+Classic298@users.noreply.github.com> Date: Wed, 14 Oct 2026 10:18:55 +0200 Subject: [PATCH] fix: pipes and tools get None instead of a file list when nothing is attached (#32380) Pipes and tools received None instead of a list of files on messages without attachments, which does not match the docs and breaks plugins that loop over the files. Pipes and tools now get an empty list in that case. Fixes #32379 --- backend/open_webui/functions.py | 2 +- backend/open_webui/utils/middleware.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/backend/open_webui/functions.py b/backend/open_webui/functions.py index ed9e31a242..20601fee7e 100644 --- a/backend/open_webui/functions.py +++ b/backend/open_webui/functions.py @@ -225,7 +225,7 @@ async def generate_function_chat_completion(request, form_data, user, models: di metadata = form_data.pop('metadata', {}) - files = metadata.get('files', []) + files = metadata.get('files') or [] tool_ids = metadata.get('tool_ids', []) # Check if tool_ids is None if tool_ids is None: diff --git a/backend/open_webui/utils/middleware.py b/backend/open_webui/utils/middleware.py index 2ea869f59e..a8186a637a 100644 --- a/backend/open_webui/utils/middleware.py +++ b/backend/open_webui/utils/middleware.py @@ -3117,7 +3117,7 @@ async def process_chat_payload(request, form_data, user, metadata, model): **extra_params, '__model__': models[task_model_id], '__messages__': form_data['messages'], - '__files__': metadata.get('files', []), + '__files__': metadata.get('files') or [], }, ) @@ -3507,7 +3507,7 @@ async def execute_tool_call(form_data, metadata, event_caller, tool_call): function=tool['callable'], extra_params={ '__messages__': form_data.get('messages', []), - '__files__': metadata.get('files', []), + '__files__': metadata.get('files') or [], }, ) result = await function(**params)