From 9958e4e0b32d06e9b4065f6bae10f46eca6c5f6c Mon Sep 17 00:00:00 2001 From: mateo-berri <277851410+mateo-berri@users.noreply.github.com> Date: Fri, 24 Jul 2026 20:24:42 -0700 Subject: [PATCH] fix: keep health check writes on the repository .table path The health_check_table property resolved through self, so tests that bind PrismaClient methods onto a MagicMock via types.MethodType got a bare MagicMock instead of the mocked prisma table and the awaits failed. Resolves HealthCheckRepository(self).table at each call site instead, which runs the same code as before the typing pass, and drops the unused property. --- litellm/proxy/utils.py | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/litellm/proxy/utils.py b/litellm/proxy/utils.py index 18070b42e6a..97f9d92a91c 100644 --- a/litellm/proxy/utils.py +++ b/litellm/proxy/utils.py @@ -3272,13 +3272,6 @@ class PrismaClient: UserNotificationsRepository(self).table, ) - @property - def health_check_table(self) -> "_PrismaTable[LiteLLM_HealthCheckTable]": - return cast( # cast-ok: repository .table is declared Any; typed table protocol pins the real shape - "_PrismaTable[LiteLLM_HealthCheckTable]", - HealthCheckRepository(self).table, - ) - def get_request_status(self, payload: Union[dict, SpendLogsPayload]) -> Literal["success", "failure"]: """ Determine if a request was successful or failed based on payload metadata. @@ -5272,7 +5265,13 @@ class PrismaClient: health_check_data.update({k: v for k, v in optional_fields.items() if v is not None}) verbose_proxy_logger.debug(f"Saving health check data: {health_check_data}") - return await self.health_check_table.create(data=health_check_data) + health_check_table = ( + cast( # cast-ok: repository .table is declared Any; typed table protocol pins the real shape + "_PrismaTable[LiteLLM_HealthCheckTable]", + HealthCheckRepository(self).table, + ) + ) + return await health_check_table.create(data=health_check_data) except Exception as e: verbose_proxy_logger.error(f"Error saving health check result for model {model_name}: {e}") @@ -5295,7 +5294,13 @@ class PrismaClient: if status_filter: where_clause["status"] = status_filter - results = await self.health_check_table.find_many( + health_check_table = ( + cast( # cast-ok: repository .table is declared Any; typed table protocol pins the real shape + "_PrismaTable[LiteLLM_HealthCheckTable]", + HealthCheckRepository(self).table, + ) + ) + results = await health_check_table.find_many( where=where_clause, order={"checked_at": "desc"}, take=limit, @@ -5314,7 +5319,13 @@ class PrismaClient: (via Prisma ``distinct`` + ``order``) so we never load the full history into memory. """ try: - return await self.health_check_table.find_many( + health_check_table = ( + cast( # cast-ok: repository .table is declared Any; typed table protocol pins the real shape + "_PrismaTable[LiteLLM_HealthCheckTable]", + HealthCheckRepository(self).table, + ) + ) + return await health_check_table.find_many( distinct=["model_id", "model_name"], order=[ {"model_id": "asc"},