From 1585f5b9209f2358146f646d8f167e507b6e0934 Mon Sep 17 00:00:00 2001 From: soojin Date: Mon, 15 Sep 2025 09:09:28 +0900 Subject: [PATCH] fix: add exception handling for logger retrieval in cold storage object key generation - Wrap get_active_custom_logger_for_callback_name call in try-except block - Gracefully handle cases where logger instance cannot be retrieved - Fall back to empty s3_path when logger lookup fails - Prevents crashes when cold storage logger is misconfigured or unavailable --- litellm/litellm_core_utils/litellm_logging.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/litellm/litellm_core_utils/litellm_logging.py b/litellm/litellm_core_utils/litellm_logging.py index 07cb1d8662b..ca8a1931648 100644 --- a/litellm/litellm_core_utils/litellm_logging.py +++ b/litellm/litellm_core_utils/litellm_logging.py @@ -4161,10 +4161,14 @@ class StandardLoggingPayloadSetup: # Get the actual s3_path from the configured cold storage logger instance s3_path = "" # default value - # Get the actual logger instance from the logger name - custom_logger = litellm.logging_callback_manager.get_active_custom_logger_for_callback_name(configured_cold_storage_logger) - if custom_logger and hasattr(custom_logger, 's3_path') and custom_logger.s3_path: - s3_path = custom_logger.s3_path + # Try to get the actual logger instance from the logger name + try: + custom_logger = litellm.logging_callback_manager.get_active_custom_logger_for_callback_name(configured_cold_storage_logger) + if custom_logger and hasattr(custom_logger, 's3_path') and custom_logger.s3_path: + s3_path = custom_logger.s3_path + except Exception: + # If any error occurs in getting the logger instance, use default empty s3_path + pass s3_object_key = get_s3_object_key( s3_path=s3_path, # Use actual s3_path from logger configuration