feat: log provider errors to console for better insights (#23379)

* fix: log provider errors that were silently swallowed

* Update main.py

* fix: wrap non-JSON SSE error responses in JSON so middleware handles them
This commit is contained in:
Classic298
2026-04-12 18:07:20 -05:00
committed by GitHub
parent 67023037f8
commit 4292358bd5
3 changed files with 23 additions and 1 deletions
+3
View File
@@ -3077,6 +3077,8 @@ async def non_streaming_chat_response_handler(response, ctx):
else:
error = str(error)
log.error('Provider returned error (non-streaming): %s', error)
await Chats.upsert_message_to_chat_by_id_and_message_id(
metadata['chat_id'],
metadata['message_id'],
@@ -3645,6 +3647,7 @@ async def streaming_chat_response_handler(response, ctx):
if not choices:
error = data.get('error', {})
if error:
log.error('Provider returned error (streaming): %s', error)
try:
await Chats.upsert_message_to_chat_by_id_and_message_id(
metadata['chat_id'],