From 455b38dcc108f1f23b9c5773e89c73e59d84aada Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Thu, 19 Dec 2024 15:59:03 -0800 Subject: [PATCH] Fix code scanning alert no. 150: Information exposure through an exception Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> --- backend/open_webui/routers/tasks.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/backend/open_webui/routers/tasks.py b/backend/open_webui/routers/tasks.py index 4990b4e08..107b99b09 100644 --- a/backend/open_webui/routers/tasks.py +++ b/backend/open_webui/routers/tasks.py @@ -395,9 +395,10 @@ async def generate_autocompletion( try: return await generate_chat_completion(request, form_data=payload, user=user) except Exception as e: + log.error(f"Error generating chat completion: {e}") return JSONResponse( - status_code=status.HTTP_400_BAD_REQUEST, - content={"detail": str(e)}, + status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, + content={"detail": "An internal error has occurred."}, )