From 13ec2685c5164bba3514fa3be6340c54a219095b Mon Sep 17 00:00:00 2001 From: Abdul Salam Mirza Date: Fri, 22 Aug 2025 01:11:57 +0200 Subject: [PATCH] fix: return JSON error message --- local_mode/main.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/local_mode/main.py b/local_mode/main.py index 56d180b..057c4f4 100644 --- a/local_mode/main.py +++ b/local_mode/main.py @@ -42,7 +42,11 @@ async def chat(request: ChatCompletionRequest): else: return JSONResponse(chat_with_codegeex(request)) except Exception as e: - return JSONResponse(e, status_code=500) + # JSONResponse expects a serializable content. Returning the exception + # object directly results in a "TypeError: Object of type ... is not JSON serializable". + # Convert the exception to a string so clients receive a meaningful + # error message instead of a server-side serialization failure. + return JSONResponse({"error": str(e)}, status_code=500) if __name__ == "__main__":