From f6d533ac2b91943ff9665144806c105943a66713 Mon Sep 17 00:00:00 2001 From: Harshit28j Date: Sat, 21 Mar 2026 04:13:09 +0530 Subject: [PATCH] fix req changes from greptile --- litellm/litellm_core_utils/litellm_logging.py | 2 +- tests/test_litellm/litellm_core_utils/test_litellm_logging.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/litellm/litellm_core_utils/litellm_logging.py b/litellm/litellm_core_utils/litellm_logging.py index c0eb3c0d729..a05cce5728e 100644 --- a/litellm/litellm_core_utils/litellm_logging.py +++ b/litellm/litellm_core_utils/litellm_logging.py @@ -589,7 +589,7 @@ class Logging(LiteLLMLoggingBaseClass): if "litellm_metadata" in kwargs and isinstance( kwargs["litellm_metadata"], dict ): - base_litellm_params["litellm_metadata"] = kwargs["litellm_metadata"] + base_litellm_params["litellm_metadata"] = kwargs["litellm_metadata"].copy() if litellm_params: base_litellm_params.update(litellm_params) diff --git a/tests/test_litellm/litellm_core_utils/test_litellm_logging.py b/tests/test_litellm/litellm_core_utils/test_litellm_logging.py index 73e9bf011d5..d1c35e15407 100644 --- a/tests/test_litellm/litellm_core_utils/test_litellm_logging.py +++ b/tests/test_litellm/litellm_core_utils/test_litellm_logging.py @@ -270,6 +270,8 @@ class TestUpdateFromKwargs: result_meta = logging_obj.litellm_params["metadata"] assert result_meta["from_caller"] is True assert result_meta["user_api_key_hash"] == "hashed-xyz" + # caller's dict must not be mutated by the merge + assert "user_api_key_hash" not in caller_metadata def test_merge_handles_metadata_none(self, logging_obj): """When metadata=None is explicitly in kwargs alongside litellm_metadata,