This commit is contained in:
Ben Langfeld 2026-10-21 06:47:24 +00:00 • committed by GitHub
commit aa98a15de0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 1 deletions

View file

@ -789,7 +789,7 @@ def _update_metadata_field(updated_kv: dict, field_name: str) -> None:
# only for a truthy value. The falsy value is still persisted below so a
# previously-set field can be cleared.
if updated_kv.get(field_name):
premium_user_check()
premium_user_check(field_name)
if field_name in updated_kv and updated_kv[field_name] is not None:
# remove field from updated_kv

View file

@ -1307,6 +1307,15 @@ class TestSetObjectMetadataFieldPremiumArg:
mock_premium.assert_called_once_with("guardrails")
class TestUpdateMetadataFieldLicenseError:
def test_license_error_names_the_blocking_field(self):
with patch("litellm.proxy.proxy_server.premium_user", False):
with pytest.raises(HTTPException) as exc_info:
update_metadata_fields({"team_id": "t1", "guardrails": ["g1"]})
assert exc_info.value.status_code == 403
assert "guardrails" in exc_info.value.detail["error"]
class TestUpdateMetadataFieldMove:
def test_none_valued_field_is_not_moved_into_metadata(self):
"""A None value must leave the field untouched (guard requires non-None)."""