open-webui/backend/open_webui
Tim Champ d827039b1b Fix task generation (title, tags, etc.) failing for direct connection chats
Two fixes for direct connection users where background task generation
(titles, tags, follow-ups) crashes with TypeError or returns 404:

1. middleware.py: Clear request.state.direct before running
   background_tasks_handler so task generation routes through the
   server-side path instead of generate_direct_chat_completion, which
   requires an active WebSocket session unavailable in this context.

2. tasks.py: Always use request.app.state.MODELS for task endpoints and
   move model validation after get_task_model_id() so the configured
   task model can resolve before the existence check runs. Previously,
   the chat model (from a direct connection) was validated before the
   task model override, causing a 404 when the chat model wasn't in the
   server's MODELS registry.

Fixes #24092, Fixes #24095

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-24 13:51:15 -04:00
..
data refac: mv backend files to /open_webui dir 2024-09-04 16:54:48 +02:00
internal chore: format 2026-04-24 18:48:21 +09:00
migrations refac 2026-04-24 18:20:10 +09:00
models chore: format 2026-04-24 18:48:21 +09:00
retrieval chore: format 2026-04-24 18:48:21 +09:00
routers Fix task generation (title, tags, etc.) failing for direct connection chats 2026-04-24 13:51:15 -04:00
socket refac 2026-04-17 13:29:51 +09:00
static chore: format 2026-04-19 22:45:54 +09:00
storage refac 2026-04-12 19:08:30 -05:00
test refac 2026-03-17 17:58:01 -05:00
tools refac 2026-04-24 18:06:19 +09:00
utils Fix task generation (title, tags, etc.) failing for direct connection chats 2026-04-24 13:51:15 -04:00
__init__.py refac (#22987) 2026-03-24 15:41:26 -05:00
alembic.ini fix: Alembic CLI commands from failing 2025-08-15 04:17:47 -04:00
config.py feat: add PaddleOCR-vl loader support and implement retrieval router infrastructure (#23945) 2026-04-24 15:19:37 +09:00
constants.py chore: format 2026-04-14 17:27:31 -05:00
env.py refac 2026-04-24 16:23:28 +09:00
functions.py refac 2026-04-21 14:31:04 +09:00
main.py chore: format 2026-04-24 18:48:21 +09:00
tasks.py refac 2026-03-17 17:58:01 -05:00