This commit is contained in:
Timothy Jaeryang Baek
2026-04-24 15:46:08 +09:00
parent f2cb63140c
commit 26711c1bcc

View File

@@ -1836,7 +1836,7 @@ async def chat_completion(
except HTTPException:
raise
except Exception as e:
log.debug(f'Error processing chat metadata: {e}')
log.warning(f'Error processing chat metadata: {e}')
raise HTTPException(
status_code=status.HTTP_400_BAD_REQUEST,
detail=str(e),
@@ -1908,6 +1908,15 @@ async def chat_completion(
except Exception:
pass
else:
# No chat_id/message_id → legacy/direct API path with no
# WebSocket error channel. We must surface the error as
# a proper HTTP response; without this the function would
# return None which FastAPI serializes as null. #23924
raise HTTPException(
status_code=status.HTTP_400_BAD_REQUEST,
detail=error_detail,
)
finally:
# MCP cleanup — MUST run in the SAME asyncio task as
# connect() because the MCP SDK's streamablehttp_client