From 494e2790af3d97fa0b7473a9c03a080c3b4c796d Mon Sep 17 00:00:00 2001 From: Classic298 <27028174+Classic298@users.noreply.github.com> Date: Sun, 8 Nov 2026 13:14:48 +0100 Subject: [PATCH] Merge pull request #33929 from Classic298/fix-chat-view-disconnect-log fix: error traceback in the log when a chat's layout save is dropped --- backend/open_webui/routers/chats.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/backend/open_webui/routers/chats.py b/backend/open_webui/routers/chats.py index 17068dec4c..207ce6318d 100644 --- a/backend/open_webui/routers/chats.py +++ b/backend/open_webui/routers/chats.py @@ -52,6 +52,7 @@ from open_webui.utils.tool_permissions import DEFAULT_TOOL_PERMISSIONS_AUTO_PROM from open_webui.utils.tool_search import DEFAULT_TOOL_SEARCH_DECISIONS_PROMPT, validate_decisions_config from pydantic import BaseModel, Field, ValidationError, field_validator, model_validator from sqlalchemy.ext.asyncio import AsyncSession +from starlette.requests import ClientDisconnect log = logging.getLogger(__name__) @@ -1424,10 +1425,13 @@ async def get_chat_view( async def bounded_chat_view(request: Request): # Bound the body before JSON/schema parsing, including chunked requests. body = bytearray() - async for chunk in request.stream(): - body.extend(chunk) - if len(body) > 1024 * 1024: - raise HTTPException(status_code=413, detail='Chat view is too large') + try: + async for chunk in request.stream(): + body.extend(chunk) + if len(body) > 1024 * 1024: + raise HTTPException(status_code=413, detail='Chat view is too large') + except ClientDisconnect: + raise HTTPException(status_code=499) try: return ChatViewStateForm.model_validate_json(bytes(body)) except ValueError: