From 2cd0c767ee82b032919ed70253b382e045482da2 Mon Sep 17 00:00:00 2001 From: Ryan Crabbe Date: Sat, 7 Mar 2026 16:40:29 -0800 Subject: [PATCH] fix: regression test --- .../test_key_management_endpoints.py | 22 ++++++------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/tests/test_litellm/proxy/management_endpoints/test_key_management_endpoints.py b/tests/test_litellm/proxy/management_endpoints/test_key_management_endpoints.py index b3e564dc73..55366bbec2 100644 --- a/tests/test_litellm/proxy/management_endpoints/test_key_management_endpoints.py +++ b/tests/test_litellm/proxy/management_endpoints/test_key_management_endpoints.py @@ -6366,21 +6366,13 @@ async def test_build_key_filter_team_id_scoped(): include_created_by_keys=True, ) - def _collect_team_id_filters(d): - results = [] - if isinstance(d, dict): - for k, v in d.items(): - if k == "team_id": - results.append(v) - else: - results.extend(_collect_team_id_filters(v)) - elif isinstance(d, list): - for item in d: - results.extend(_collect_team_id_filters(item)) - return results - - team_id_filters = _collect_team_id_filters(where) - assert "team-A" in team_id_filters, f"Expected global team_id='team-A' AND filter, got: {where}" + # The team_id filter must be a direct child of the outermost AND, + # not buried inside an OR branch (which was the bug). + assert "AND" in where, f"Expected top-level AND, got: {where}" + outer_and = where["AND"] + assert {"team_id": "team-A"} in outer_and, ( + f"Expected {{'team_id': 'team-A'}} as a direct AND condition, got: {outer_and}" + ) @pytest.mark.asyncio