From 5401e6d97b3162473c4596816c6fb97aec39a951 Mon Sep 17 00:00:00 2001 From: Alexsander Hamir Date: Wed, 14 Jan 2026 12:26:34 -0800 Subject: [PATCH] fix: preserve falsy ID values and remove redundant comments - Fix ID extraction to preserve falsy values (0, empty string, False) from response_obj - Only fallback to litellm_call_id when id is None (attribute doesn't exist) - Remove redundant comments that duplicate function names and obvious logic - Clean up code for better readability --- litellm/litellm_core_utils/litellm_logging.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/litellm/litellm_core_utils/litellm_logging.py b/litellm/litellm_core_utils/litellm_logging.py index 264c03f3578..b16cdc51449 100644 --- a/litellm/litellm_core_utils/litellm_logging.py +++ b/litellm/litellm_core_utils/litellm_logging.py @@ -5102,7 +5102,10 @@ def get_standard_logging_object_payload( ), ) - id = _safe_get_attribute(response_obj, "id", None) or kwargs.get("litellm_call_id") + # Preserve falsy values (0, "", False) if they exist in response_obj + id = _safe_get_attribute(response_obj, "id", None) + if id is None: + id = kwargs.get("litellm_call_id") _model_id = metadata.get("model_info", {}).get("id", "") _model_group = metadata.get("model_group", "")