From c4fa1c5180f25bb063c4cd420da5cee0e5f4fe5b Mon Sep 17 00:00:00 2001 From: LeizhenZhang Date: Mon, 2 Nov 2026 18:34:19 -0600 Subject: [PATCH] fix(cache): retain exception names in redacted tracebacks Signed-off-by: LeizhenZhang --- litellm/caching/redis_cache.py | 4 +++- tests/unit/caching/test_redis_cache.py | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/litellm/caching/redis_cache.py b/litellm/caching/redis_cache.py index 920111bfb36..59a5131f7db 100644 --- a/litellm/caching/redis_cache.py +++ b/litellm/caching/redis_cache.py @@ -555,7 +555,9 @@ def log_redis_failure( if isinstance(exc, RedisCircuitBreakerOpenError): logger.debug("%s: %s", message, reason, stacklevel=2) return - exc_info: Final = (type(exc), Exception(reason), exc.__traceback__) if with_traceback else None + exc_info: Final = ( + (Exception, Exception(f"{type(exc).__name__}: {reason}"), exc.__traceback__) if with_traceback else None + ) if not is_redis_timeout_failure(exc): logger.log(level, "%s: %s", message, reason, exc_info=exc_info, stacklevel=2) return diff --git a/tests/unit/caching/test_redis_cache.py b/tests/unit/caching/test_redis_cache.py index 102e31ce49f..19813199487 100644 --- a/tests/unit/caching/test_redis_cache.py +++ b/tests/unit/caching/test_redis_cache.py @@ -1784,6 +1784,7 @@ def test_log_redis_failure_redacts_traceback_and_exception_chain( assert SENSITIVE_CACHE_KEY not in caplog.text assert "private customer message" not in caplog.text assert "Traceback (most recent call last)" in caplog.text + assert ("RuntimeError" if chained else "ResponseError") in caplog.text assert "Redis failed" in caplog.text