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(proxy): apply DB-stored callback redaction settings before logger init

ryan6c13e0912b43
diff --git a/litellm/constants.py b/litellm/constants.py
index bbeb4846e27..4bc2e4e0d26 100644
--- a/litellm/constants.py
+++ b/litellm/constants.py
@@ -1853,6 +1853,12 @@ LITELLM_SETTINGS_SAFE_DB_OVERRIDES: Final = [
"max_ui_session_budget",
"budget_rollover",
"mcp_tool_search",
+ "turn_off_message_logging",
+ "datadog_params",
+ "datadog_llm_observability_params",
+ "newrelic_params",
+ "pointfive_params",
+ "aws_sqs_callback_params",
]
SPECIAL_LITELLM_AUTH_TOKEN: Final = ["ui-token"]
DEFAULT_MANAGEMENT_OBJECT_IN_MEMORY_CACHE_TTL = int(os.getenv("DEFAULT_MANAGEMENT_OBJECT_IN_MEMORY_CACHE_TTL", 60))
diff --git a/tests/test_litellm/proxy/test_proxy_server.py b/tests/test_litellm/proxy/test_proxy_server.py
index f71f9c20f3b..75741b125cb 100644
--- a/tests/test_litellm/proxy/test_proxy_server.py
+++ b/tests/test_litellm/proxy/test_proxy_server.py
@@ -11766,6 +11766,42 @@ def test_prompt_caching_settings_propagate_on_config_reload(monkeypatch, field_n
assert getattr(litellm, field_name) == db_value
+async def test_db_stored_datadog_redaction_settings_apply_before_logger_init(monkeypatch):
+ """A DB-only litellm_settings row that pairs success_callback: ["datadog"] with
+ datadog_params.turn_off_message_logging: true must build the DataDogLogger redacted, the
+ same as the identical block in YAML. Regression for the redaction keys being absent from
+ the safe-override allowlist while the callback half of the row was honoured."""
+ import litellm.proxy.proxy_server as ps
+ from litellm.integrations.datadog.datadog import DataDogLogger
+ from litellm.litellm_core_utils import litellm_logging
+
+ monkeypatch.setenv("DD_API_KEY", "test-key")
+ monkeypatch.setenv("DD_SITE", "us5.datadoghq.com")
+ monkeypatch.setattr(litellm, "datadog_params", None)
+ monkeypatch.setattr(litellm, "turn_off_message_logging", False)
+ monkeypatch.setattr(litellm, "success_callback", [])
+ monkeypatch.setattr(litellm, "_async_success_callback", [])
+ monkeypatch.setattr(litellm, "failure_callback", [])
+ monkeypatch.setattr(litellm, "_async_failure_callback", [])
+ monkeypatch.setattr(litellm, "callbacks", [])
+ monkeypatch.setattr(litellm_logging, "_in_memory_loggers", [])
+
+ db_row = {
+ "success_callback": ["datadog"],
+ "datadog_params": {"turn_off_message_logging": True},
+ "turn_off_message_logging": True,
+ }
+ pc = ps.ProxyConfig()
+ pc._apply_litellm_settings_db_values(pc._prepared_db_settings_values("litellm_settings", db_row))
+ pc._add_callbacks_from_db_config({"litellm_settings": db_row})
+
+ datadog_loggers = [cb for cb in litellm.success_callback if isinstance(cb, DataDogLogger)]
+ assert len(datadog_loggers) == 1
+ assert datadog_loggers[0].turn_off_message_logging is True
+ assert litellm.turn_off_message_logging is True
+
+
def test_get_config_list_marks_untouched_prompt_caching_flag_as_not_set(monkeypatch):
"""The flag defaults to False rather than None, so a plain 'is not None' check would
report the default as 'In Config' and imply an admin had set it."""