From d7d7ef02da2ceb816f1341f12c4c0f6537d49487 Mon Sep 17 00:00:00 2001 From: mateo-berri <277851410+mateo-berri@users.noreply.github.com> Date: Fri, 6 Nov 2026 07:35:46 -0800 Subject: [PATCH] fix(proxy): skip the key metadata lookup when the daily rows carry no keys --- litellm/proxy/management_endpoints/common_daily_activity.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/litellm/proxy/management_endpoints/common_daily_activity.py b/litellm/proxy/management_endpoints/common_daily_activity.py index 232b7a998eb..054b7e858a1 100644 --- a/litellm/proxy/management_endpoints/common_daily_activity.py +++ b/litellm/proxy/management_endpoints/common_daily_activity.py @@ -927,6 +927,8 @@ async def _key_metadata_unless_database_fails( rows: Sequence[GroupingSetsRow] | Sequence[EntityRollupRow] | Sequence[DailySpendRecord], ) -> Mapping[str, KeyMetadataRow] | None: api_keys: Final = frozenset(row.api_key for row in rows if row.api_key and row.api_key != PTU_SENTINEL_API_KEY) + if not api_keys: + return MappingProxyType({}) return await unless_database_fails( repository.key_metadata(api_keys, spend_logs_window(frozenset(row.date for row in rows))), None,