From 8b1af8def50642493d6be6627936edfc4dba1535 Mon Sep 17 00:00:00 2001 From: Jesus Velarde Date: Sat, 7 Nov 2026 17:33:35 -0800 Subject: [PATCH] fix(proxy): log a dropped credential reference as an error so /key/health reports it --- litellm/proxy/common_utils/callback_utils.py | 2 +- .../unit/proxy/common_utils/test_callback_utils.py | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/litellm/proxy/common_utils/callback_utils.py b/litellm/proxy/common_utils/callback_utils.py index c80e470003f..ecec3f08dc4 100644 --- a/litellm/proxy/common_utils/callback_utils.py +++ b/litellm/proxy/common_utils/callback_utils.py @@ -767,7 +767,7 @@ def _with_credential(entry: Mapping[str, object]) -> Mapping[str, object] | None if name in CALLBACK_VAR_NAMES and value is not None } if not credential_vars: - verbose_proxy_logger.warning( + verbose_proxy_logger.error( "Ignoring key logging entry for %s: credential %r is not defined or holds no logging values", entry.get("callback_name"), credential_name, diff --git a/tests/unit/proxy/common_utils/test_callback_utils.py b/tests/unit/proxy/common_utils/test_callback_utils.py index f57ab902c45..29e54b838d8 100644 --- a/tests/unit/proxy/common_utils/test_callback_utils.py +++ b/tests/unit/proxy/common_utils/test_callback_utils.py @@ -1,5 +1,6 @@ import copy import json +import logging import sys from types import ModuleType, SimpleNamespace from typing import Final @@ -826,6 +827,18 @@ def test_key_logging_entries_drops_an_entry_whose_credential_supplies_no_logging assert key_logging_entries({"logging": entries}) == (kept,) +def test_a_dropped_credential_reference_is_logged_as_an_error_so_key_health_reports_it( + monkeypatch: pytest.MonkeyPatch, caplog: pytest.LogCaptureFixture +) -> None: + monkeypatch.setattr(litellm, "credential_list", []) + entry: Final = {"callback_name": "arize", "litellm_credential_name": "missing", "callback_vars": {}} + + with caplog.at_level(logging.WARNING): + key_logging_entries({"logging": [entry]}) + + assert [record.levelno for record in caplog.records if "missing" in record.getMessage()] == [logging.ERROR] + + def test_key_logging_entries_drops_an_entry_whose_credential_is_not_defined(monkeypatch: pytest.MonkeyPatch) -> None: monkeypatch.setattr(litellm, "credential_list", [_credential("space-a", {"arize_api_key": "key-a"})]) kept: Final = {"callback_name": "langfuse", "callback_vars": {"langfuse_public_key": "pk"}}