From 8e6300f0bf501b57e431d41099e1cb0686e5f8f1 Mon Sep 17 00:00:00 2001 From: Yuneng Jiang Date: Sat, 4 Apr 2026 14:25:19 -0700 Subject: [PATCH] fix: replace unsupported Prisma JSON path filter in _get_team_deployments prisma-client-py 0.11.0 does not support JSON path filtering (path/equals) on Json fields. Replace with model_name prefix query + Python-side team_id confirmation. Co-Authored-By: Claude Opus 4.6 (1M context) --- .../model_management_endpoints.py | 27 ++++++++++++++----- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/litellm/proxy/management_endpoints/model_management_endpoints.py b/litellm/proxy/management_endpoints/model_management_endpoints.py index 2ca8e3daba..754727d471 100644 --- a/litellm/proxy/management_endpoints/model_management_endpoints.py +++ b/litellm/proxy/management_endpoints/model_management_endpoints.py @@ -485,18 +485,31 @@ async def _get_team_deployments( Centralizes team deployment queries to ensure consistent filtering and error handling. This is the established helper pattern for team deployment DB access in this module. - Note: Direct Prisma call is intentional here as this IS the helper function that - encapsulates the DB access pattern for team deployments. + Note: prisma-client-py 0.11.0 does not support JSON path filtering, so we filter + by the model_name prefix (team models use "model_name_{team_id}_*") and confirm + team_id in model_info with Python-side filtering. """ + prefix = f"model_name_{team_id}_" response = await prisma_client.db.litellm_proxymodeltable.find_many( where={ - "model_info": { - "path": ["team_id"], - "equals": team_id, - } + "model_name": {"startswith": prefix}, } ) - return response if response else [] + if not response: + return [] + + # Confirm team_id in model_info (defensive check) + result = [] + for row in response: + model_info = row.model_info + if isinstance(model_info, str): + try: + model_info = json.loads(model_info) + except (TypeError, ValueError): + continue + if isinstance(model_info, dict) and model_info.get("team_id") == team_id: + result.append(row) + return result async def _update_existing_team_model_assignment(