Skip to content

Commit f78b238

Browse files
fix: prevent pipeline filter from corrupting payload on HTTP error (open-webui#22445)
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 <ethanchang32@gmail.com>
1 parent bbbe2b6 commit f78b238

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

backend/open_webui/routers/pipelines.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ async def process_pipeline_inlet_filter(request, payload, user, models):
9292
json=request_data,
9393
ssl=AIOHTTP_CLIENT_SESSION_SSL,
9494
) as response:
95-
payload = await response.json()
9695
response.raise_for_status()
96+
payload = await response.json()
9797
except aiohttp.ClientResponseError as e:
9898
res = (
9999
await response.json()
@@ -145,8 +145,8 @@ async def process_pipeline_outlet_filter(request, payload, user, models):
145145
json=request_data,
146146
ssl=AIOHTTP_CLIENT_SESSION_SSL,
147147
) as response:
148-
payload = await response.json()
149148
response.raise_for_status()
149+
payload = await response.json()
150150
except aiohttp.ClientResponseError as e:
151151
try:
152152
res = (

0 commit comments

Comments
 (0)