From 99b4d17ee851187363e6d2f39097d8767d91caac Mon Sep 17 00:00:00 2001 From: The Mavik <179817126+themavik@users.noreply.github.com> Date: Fri, 13 Feb 2026 10:15:30 +0530 Subject: [PATCH] fix: guard against None litellm_metadata in batch logging (#20832) When litellm_metadata is explicitly set to None in litellm_params, `dict.get("litellm_metadata", {})` returns None (not the default {}), because the key exists. The subsequent .get() call on None raises `AttributeError: 'NoneType' object has no attribute 'get'`. Use `or {}` instead, consistent with line 4924 in the same file. Fixes #15836 --- litellm/litellm_core_utils/litellm_logging.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/litellm/litellm_core_utils/litellm_logging.py b/litellm/litellm_core_utils/litellm_logging.py index 82a7af64f97..80a333f52b6 100644 --- a/litellm/litellm_core_utils/litellm_logging.py +++ b/litellm/litellm_core_utils/litellm_logging.py @@ -2331,7 +2331,7 @@ class Logging(LiteLLMLoggingBaseClass): result, LiteLLMBatch ): litellm_params = self.litellm_params or {} - litellm_metadata = litellm_params.get("litellm_metadata", {}) + litellm_metadata = litellm_params.get("litellm_metadata") or {} if ( litellm_metadata.get("batch_ignore_default_logging", False) is True ): # polling job will query these frequently, don't spam db logs