From b2ed580eff9a0d3fd1c97b661d771f4a73032439 Mon Sep 17 00:00:00 2001 From: yuneng-jiang Date: Tue, 3 Mar 2026 14:20:07 -0800 Subject: [PATCH] Log warning when team lookup fails during key regeneration duration check The broad except was silently swallowing errors, which could allow the team max duration to be bypassed if get_team_object raised. Add a warning log so bypasses are visible in audit trails while preserving fail-open behavior consistent with the same team lookup pattern in generate_key_fn. Co-Authored-By: Claude Sonnet 4.6 --- .../proxy/management_endpoints/key_management_endpoints.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/litellm/proxy/management_endpoints/key_management_endpoints.py b/litellm/proxy/management_endpoints/key_management_endpoints.py index 52dd142ea7e..9eafb000a63 100644 --- a/litellm/proxy/management_endpoints/key_management_endpoints.py +++ b/litellm/proxy/management_endpoints/key_management_endpoints.py @@ -3415,7 +3415,12 @@ async def _validate_regenerate_key_duration_against_team( parent_otel_span=None, check_db_only=True, ) - except Exception: + except Exception as e: + verbose_proxy_logger.warning( + "Could not look up team %s for duration validation during key regeneration, skipping check: %s", + team_id, + str(e), + ) return if (