fix(logging): tolerate null callback_settings entries

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
yucheng 2026-09-14 22:37:45 +00:00
parent 29f1ecd826
commit 8bb7e19a65
2 changed files with 22 additions and 3 deletions

View file

@ -5278,9 +5278,8 @@ def _get_custom_logger_settings_from_proxy_server(callback_name: str) -> dict:
langsmith:
turn_off_message_logging: true
"""
if litellm.callback_settings:
return dict(litellm.callback_settings.get(callback_name, {}))
return {}
callback_settings: Final = litellm.callback_settings.get(callback_name) if litellm.callback_settings else None
return dict(callback_settings) if isinstance(callback_settings, dict) else {}
def use_custom_pricing_for_model(litellm_params: dict | None) -> bool:

View file

@ -1046,6 +1046,26 @@ def test_init_custom_logger_applies_callback_settings_turn_off_message_logging(m
logging_module._in_memory_loggers.clear()
def test_init_custom_logger_tolerates_null_callback_settings(monkeypatch):
from litellm.litellm_core_utils import litellm_logging as logging_module
monkeypatch.setattr(litellm, "callback_settings", {"langsmith": None})
logging_module._in_memory_loggers.clear()
try:
logger = logging_module._init_custom_logger_compatible_class(
logging_integration="langsmith",
internal_usage_cache=None,
llm_router=None,
custom_logger_init_args={},
)
assert logger is not None
assert logger.turn_off_message_logging is False
assert logging_module._get_custom_logger_settings_from_proxy_server("langsmith") == {}
finally:
logging_module._in_memory_loggers.clear()
def test_success_handler_redacts_custom_logger_payload_per_callback(logging_obj):
redacting_logger = _RecordingCustomLogger(turn_off_message_logging=True)
plain_logger = _RecordingCustomLogger(turn_off_message_logging=False)