From 001043ba0592392efa6f67e4355778deb72366d9 Mon Sep 17 00:00:00 2001 From: Chaos Yu Date: Sat, 5 Apr 2025 11:39:12 +0800 Subject: [PATCH] make sure metadata available and have a value (#9764) --- litellm/proxy/litellm_pre_call_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/litellm/proxy/litellm_pre_call_utils.py b/litellm/proxy/litellm_pre_call_utils.py index dade6c933e6..785ad8dc290 100644 --- a/litellm/proxy/litellm_pre_call_utils.py +++ b/litellm/proxy/litellm_pre_call_utils.py @@ -528,7 +528,7 @@ async def add_litellm_data_to_request( # noqa: PLR0915 _metadata_variable_name = _get_metadata_variable_name(request) - if _metadata_variable_name not in data: + if data.get(_metadata_variable_name, None) is None: data[_metadata_variable_name] = {} # We want to log the "metadata" from the client side request. Avoid circular reference by not directly assigning metadata to itself.