fix(cache): retain exception names in redacted tracebacks

Signed-off-by: LeizhenZhang <zhangleizhen645@gmail.com>
This commit is contained in:
LeizhenZhang 2026-11-02 18:34:19 -06:00
parent 26631bca72
commit c4fa1c5180
2 changed files with 4 additions and 1 deletions

View file

@ -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

View file

@ -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