fix: enable secret redaction by default, use LITELLM_DISABLE_REDACT_SECRETS to opt out

This commit is contained in:
Ryan Crabbe 2026-03-12 09:13:39 -07:00
parent bd16532431
commit ff5bd96b59
2 changed files with 3 additions and 3 deletions

View file

@ -17,7 +17,7 @@ if set_verbose is True:
"`litellm.set_verbose` is deprecated. Please set `os.environ['LITELLM_LOG'] = 'DEBUG'` for debug logs."
)
_ENABLE_SECRET_REDACTION = os.getenv("LITELLM_REDACT_SECRETS", "").lower() == "true"
_ENABLE_SECRET_REDACTION = os.getenv("LITELLM_DISABLE_REDACT_SECRETS", "").lower() != "true"
_REDACTED = "REDACTED"

View file

@ -17,7 +17,7 @@ SECRET = "sk-proj-abc123def456ghi789jklmnopqrst"
@pytest.fixture(autouse=True)
def _enable_redaction():
"""Enable secret redaction for all tests in this module."""
"""Ensure secret redaction is on (the default) for all tests in this module."""
with patch("litellm._logging._ENABLE_SECRET_REDACTION", True):
yield
@ -133,7 +133,7 @@ def test_filter_redacts_extra_fields():
def test_disable_redaction_passes_secrets_through():
"""When _ENABLE_SECRET_REDACTION is False, secrets pass through."""
"""When LITELLM_DISABLE_REDACT_SECRETS=true, secrets pass through."""
with patch("litellm._logging._ENABLE_SECRET_REDACTION", False):
record = logging.LogRecord(
name="test",