fix(proxy): log a dropped credential reference as an error so /key/health reports it

This commit is contained in:
Jesus Velarde 2026-11-07 17:33:35 -08:00
parent 77482c46cd
commit 8b1af8def5
2 changed files with 14 additions and 1 deletions

View file

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

View file

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