Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

fix: stop leaking Python tracebacks in streaming SSE error responses (#20850)

The Mavik6b4db0caebe4
diff --git a/litellm/proxy/proxy_server.py b/litellm/proxy/proxy_server.py
index 294294cdda7..a0ebe277fef 100644
--- a/litellm/proxy/proxy_server.py
+++ b/litellm/proxy/proxy_server.py
@@ -4705,8 +4705,10 @@ async def async_assistants_data_generator(
if isinstance(e, HTTPException):
raise e
else:
- error_traceback = traceback.format_exc()
- error_msg = f"{str(e)}\n\n{error_traceback}"
+ # Only include the error message, not the traceback.
+ # The traceback is already logged above via verbose_proxy_logger.exception().
+ # Including it in the SSE response leaks internal details to clients.
+ error_msg = str(e)
proxy_exception = ProxyException(
message=getattr(e, "message", error_msg),
@@ -4856,8 +4858,10 @@ async def async_data_generator(
elif isinstance(e, StreamingCallbackError):
error_msg = str(e)
else:
- error_traceback = traceback.format_exc()
- error_msg = f"{str(e)}\n\n{error_traceback}"
+ # Only include the error message, not the traceback.
+ # The traceback is already logged above via verbose_proxy_logger.exception().
+ # Including it in the SSE response leaks internal details to clients.
+ error_msg = str(e)
proxy_exception = ProxyException(
message=getattr(e, "message", error_msg),