Skip to content

Commit 1585f5b

Browse files
committed
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
1 parent 488b373 commit 1585f5b

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

litellm/litellm_core_utils/litellm_logging.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4161,10 +4161,14 @@ def _generate_cold_storage_object_key(
41614161
# Get the actual s3_path from the configured cold storage logger instance
41624162
s3_path = "" # default value
41634163

4164-
# Get the actual logger instance from the logger name
4165-
custom_logger = litellm.logging_callback_manager.get_active_custom_logger_for_callback_name(configured_cold_storage_logger)
4166-
if custom_logger and hasattr(custom_logger, 's3_path') and custom_logger.s3_path:
4167-
s3_path = custom_logger.s3_path
4164+
# Try to get the actual logger instance from the logger name
4165+
try:
4166+
custom_logger = litellm.logging_callback_manager.get_active_custom_logger_for_callback_name(configured_cold_storage_logger)
4167+
if custom_logger and hasattr(custom_logger, 's3_path') and custom_logger.s3_path:
4168+
s3_path = custom_logger.s3_path
4169+
except Exception:
4170+
# If any error occurs in getting the logger instance, use default empty s3_path
4171+
pass
41684172

41694173
s3_object_key = get_s3_object_key(
41704174
s3_path=s3_path, # Use actual s3_path from logger configuration

0 commit comments

Comments
 (0)