mirror of
https://github.com/tiennm99/litellm.git
synced 2026-08-06 04:23:40 +00:00
fix(proxy): always merge caller-supplied tags into request metadata
Caller-supplied tags (`x-litellm-tags` header, body `tags`, `metadata.tags`) were silently dropped unless the key/team had `metadata.allow_client_tags: true` set. Restore the documented behavior: tags from the request always flow into `metadata.tags` and union with any admin-configured static tags from key/team/project metadata. Removes the `allow_client_tags` opt-in flag from the pre-call pipeline. The flag was only ever read here; it has no schema or endpoint footprint, so leftover values in existing key metadata are inert. Test cleanup mirrors the simplification: drop the three tests that verified the strip-when-not-opted-in path, drop the `allow_client_tags` fixture lines from the merge/union tests.
This commit is contained in:
@@ -167,13 +167,9 @@ 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,
|
||||
@@ -909,13 +905,12 @@ async def test_add_litellm_data_to_request_duplicate_tags(
|
||||
mock_request.headers = {}
|
||||
mock_request.state = State()
|
||||
|
||||
# Setup key with tags in metadata. Opt into client-supplied tags so the
|
||||
# request_tags are preserved for the merge under test.
|
||||
# Setup key with tags in metadata.
|
||||
user_api_key_dict = UserAPIKeyAuth(
|
||||
api_key="test_api_key",
|
||||
user_id="test_user_id",
|
||||
org_id="test_org_id",
|
||||
metadata={"tags": key_tags, "allow_client_tags": True},
|
||||
metadata={"tags": key_tags},
|
||||
)
|
||||
|
||||
# Setup request data with tags
|
||||
|
||||
Reference in New Issue
Block a user