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
This commit is contained in:
The Mavik 2026-02-13 10:15:30 +05:30 • committed by GitHub
parent 68d2306dd4
commit 99b4d17ee8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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