From f78b238b40a9dc927e6cbf4c6ee9bee5dfabdca2 Mon Sep 17 00:00:00 2001 From: Alvin Tang <104285249+alvinttang@users.noreply.github.com> Date: Mon, 9 Mar 2026 05:44:35 +0800 Subject: [PATCH] fix: prevent pipeline filter from corrupting payload on HTTP error (#22445) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In both inlet and outlet filter processing, response.json() was called BEFORE response.raise_for_status(). When a filter endpoint returns an HTTP error, the user's chat payload gets silently overwritten with the error response body. If the error is not caught, the corrupted payload propagates through subsequent filters and into the chat completion. Swapped the order so raise_for_status() runs first — payload is only updated on success. Co-authored-by: gambletan --- backend/open_webui/routers/pipelines.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/open_webui/routers/pipelines.py b/backend/open_webui/routers/pipelines.py index ebedd3027d..fa1b77a09c 100644 --- a/backend/open_webui/routers/pipelines.py +++ b/backend/open_webui/routers/pipelines.py @@ -92,8 +92,8 @@ async def process_pipeline_inlet_filter(request, payload, user, models): json=request_data, ssl=AIOHTTP_CLIENT_SESSION_SSL, ) as response: - payload = await response.json() response.raise_for_status() + payload = await response.json() except aiohttp.ClientResponseError as e: res = ( await response.json() @@ -145,8 +145,8 @@ async def process_pipeline_outlet_filter(request, payload, user, models): json=request_data, ssl=AIOHTTP_CLIENT_SESSION_SSL, ) as response: - payload = await response.json() response.raise_for_status() + payload = await response.json() except aiohttp.ClientResponseError as e: try: res = (