From d9da2db0435dab3229e7f62a3502e78311530cd6 Mon Sep 17 00:00:00 2001 From: wadrzl55333 Date: Fri, 28 Aug 2026 21:34:08 +0800 Subject: [PATCH] refactor(proxy): reuse DB callback helper for config-file registration The config-file loop reached into litellm._known_custom_logger_compatible_callbacks (2 new private accesses) which trips the basedpyright per-rule budget. Route it through the existing _add_callback_from_db_to_in_memory_litellm_callbacks helper instead: same known-list check, same instance registration, plus the string fallback now living in _add_custom_logger_callback_to_specific_event for when the custom-logger class cannot initialize. Net private API surface change vs base: zero. --- litellm/proxy/proxy_server.py | 20 +++++++++++--------- litellm/utils.py | 13 ------------- 2 files changed, 11 insertions(+), 22 deletions(-) diff --git a/litellm/proxy/proxy_server.py b/litellm/proxy/proxy_server.py index 7abe509fa1d..c2e506ec00b 100644 --- a/litellm/proxy/proxy_server.py +++ b/litellm/proxy/proxy_server.py @@ -702,7 +702,7 @@ from litellm.types.secret_managers.main import ( ) from litellm.types.utils import CredentialItem, CustomHuggingfaceTokenizer, RawRequestTypedDict, StandardLoggingPayload from litellm.types.utils import ModelInfo as ModelMapInfo -from litellm.utils import _add_custom_logger_callback_to_specific_event, register_config_custom_logger_callback +from litellm.utils import _add_custom_logger_callback_to_specific_event try: from litellm._version import version @@ -5121,10 +5121,11 @@ class ProxyConfig: ) # these are litellm callbacks - "langfuse", "sentry", "wandb" else: - if callback in litellm._known_custom_logger_compatible_callbacks: - register_config_custom_logger_callback(callback, "success") - else: - litellm.logging_callback_manager.add_litellm_success_callback(callback) + self._add_callback_from_db_to_in_memory_litellm_callbacks( + callback=callback, + event_types=["success"], + existing_callbacks=litellm.success_callback, + ) if "prometheus" in callback: from litellm.integrations.prometheus import ( PrometheusLogger, @@ -5151,10 +5152,11 @@ class ProxyConfig: ) # these are litellm callbacks - "langfuse", "sentry", "wandb" else: - if callback in litellm._known_custom_logger_compatible_callbacks: - register_config_custom_logger_callback(callback, "failure") - else: - litellm.logging_callback_manager.add_litellm_failure_callback(callback) + self._add_callback_from_db_to_in_memory_litellm_callbacks( + callback=callback, + event_types=["failure"], + existing_callbacks=litellm.failure_callback, + ) print( # noqa: T201 f"{blue_color_code} Initialized Failure Callbacks - {litellm.failure_callback} {reset_color_code}" ) diff --git a/litellm/utils.py b/litellm/utils.py index 2d5af878778..1c9e14b38eb 100644 --- a/litellm/utils.py +++ b/litellm/utils.py @@ -604,19 +604,6 @@ def _add_custom_logger_callback_to_specific_event(callback: str, logging_event: litellm.logging_callback_manager.add_litellm_failure_callback(callback) -def register_config_custom_logger_callback(callback: str, logging_event: Literal["success", "failure"]) -> None: - """Register a config-file custom-logger name as an instance, not a string. - - Config-file ``success_callback`` / ``failure_callback`` strings previously - landed in ``litellm.success_callback`` as bare strings; pass-through - endpoints log through the async path only, so they never saw them. - Registering the custom-logger instance covers both paths. Falls back to - string registration when the class cannot be initialized (e.g. missing env - credentials), so standard-route logging keeps working. - """ - _add_custom_logger_callback_to_specific_event(callback, logging_event) - - def _custom_logger_class_exists_in_success_callbacks( callback_class: CustomLogger, ) -> bool: