fix: properly raise exceptions instead of returning them in chat.py (#20276)
Change 'return Exception(...)' to 'raise Exception(...)' in chat_completed() and chat_action() functions. Returning an exception object instead of raising it causes errors to be silently swallowed, breaking error propagation.
This commit is contained in:
@@ -310,7 +310,7 @@ async def chat_completed(request: Request, form_data: dict, user: Any):
|
|||||||
try:
|
try:
|
||||||
data = await process_pipeline_outlet_filter(request, data, user, models)
|
data = await process_pipeline_outlet_filter(request, data, user, models)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return Exception(f"Error: {e}")
|
raise Exception(f"Error: {e}")
|
||||||
|
|
||||||
metadata = {
|
metadata = {
|
||||||
"chat_id": data["chat_id"],
|
"chat_id": data["chat_id"],
|
||||||
@@ -346,7 +346,7 @@ async def chat_completed(request: Request, form_data: dict, user: Any):
|
|||||||
)
|
)
|
||||||
return result
|
return result
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return Exception(f"Error: {e}")
|
raise Exception(f"Error: {e}")
|
||||||
|
|
||||||
|
|
||||||
async def chat_action(request: Request, action_id: str, form_data: dict, user: Any):
|
async def chat_action(request: Request, action_id: str, form_data: dict, user: Any):
|
||||||
@@ -442,6 +442,6 @@ async def chat_action(request: Request, action_id: str, form_data: dict, user: A
|
|||||||
data = action(**params)
|
data = action(**params)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return Exception(f"Error: {e}")
|
raise Exception(f"Error: {e}")
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
|||||||
Reference in New Issue
Block a user