fix: prevent pipeline filter from corrupting payload on HTTP error (#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>
This commit is contained in:
Alvin Tang 2026-03-09 05:44:35 +08:00 committed by GitHub
parent bbbe2b66b4
commit f78b238b40
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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 = (