From 8526628a8fac6400b75b5bdb78958a656fa3abd4 Mon Sep 17 00:00:00 2001 From: user <70670632+stuxf@users.noreply.github.com> Date: Thu, 16 Apr 2026 22:40:43 +0000 Subject: [PATCH] test: update tag-merge tests for default-deny client tag policy Two pre-existing tests codified the pre-fix behavior where any caller- supplied metadata.tags would flow through to spend logs and routing: - test_add_key_or_team_level_spend_logs_metadata_to_request exercised the request/key/team tag merge. Set allow_client_tags=True on the key metadata so the merge path is still tested under the new regime. - test_create_file_with_nested_litellm_metadata asserted that litellm_metadata[tags] form-data propagated to the handler. Drop the tag field; the test still proves nested form-parser correctness via spend_logs_metadata and environment. --- tests/proxy_unit_tests/test_proxy_utils.py | 4 ++++ .../proxy/openai_files_endpoint/test_files_endpoint.py | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/proxy_unit_tests/test_proxy_utils.py b/tests/proxy_unit_tests/test_proxy_utils.py index 9f5f14457e..a84bf7a4e7 100644 --- a/tests/proxy_unit_tests/test_proxy_utils.py +++ b/tests/proxy_unit_tests/test_proxy_utils.py @@ -162,9 +162,13 @@ async def test_add_key_or_team_level_spend_logs_metadata_to_request( print(f"team_sl_metadata: {team_sl_metadata}") mock_request.url.path = "/chat/completions" + # Opt the key into client-supplied tags so request_tags are preserved + # and merged with admin-configured key/team tags. Without this flag, + # request_tags would be stripped by add_litellm_data_to_request. key_metadata = { "tags": key_tags, "spend_logs_metadata": key_sl_metadata, + "allow_client_tags": True, } team_metadata = { "tags": team_tags, diff --git a/tests/test_litellm/proxy/openai_files_endpoint/test_files_endpoint.py b/tests/test_litellm/proxy/openai_files_endpoint/test_files_endpoint.py index 09d11388d8..49fff6de0f 100644 --- a/tests/test_litellm/proxy/openai_files_endpoint/test_files_endpoint.py +++ b/tests/test_litellm/proxy/openai_files_endpoint/test_files_endpoint.py @@ -1295,7 +1295,6 @@ def test_create_file_with_nested_litellm_metadata( "target_model_names": "gpt-3.5-turbo", "litellm_metadata[spend_logs_metadata][owner]": "john_doe", "litellm_metadata[spend_logs_metadata][team]": "engineering", - "litellm_metadata[tags]": "production", "litellm_metadata[environment]": "prod", }, headers={"Authorization": "Bearer test-key"}, @@ -1306,11 +1305,12 @@ def test_create_file_with_nested_litellm_metadata( result = response.json() assert result["id"] == "file-test-123" - # Verify nested metadata was correctly parsed + # Verify nested metadata was correctly parsed. + # Note: caller-supplied `tags` is stripped by default; test removed + # to keep the parsing test focused on parser correctness. assert "spend_logs_metadata" in captured_litellm_metadata assert captured_litellm_metadata["spend_logs_metadata"]["owner"] == "john_doe" assert captured_litellm_metadata["spend_logs_metadata"]["team"] == "engineering" - assert captured_litellm_metadata["tags"] == "production" assert captured_litellm_metadata["environment"] == "prod"