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 <noreply@anthropic.com>
This commit is contained in:
yuneng-jiang 2026-03-03 14:20:07 -08:00
parent 3ed3255c47
commit b2ed580eff

View file

@ -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 (