mirror of
https://github.com/tiennm99/litellm.git
synced 2026-07-10 19:04:29 +00:00
f4e23c97fd
Failure spend logs were missing key metadata (key alias, user ID, team ID, team alias) in two scenarios: 1. Auth errors (401 ProxyException): auth_exception_handler creates a minimal UserAPIKeyAuth with only api_key and request_route set — all other fields are null. The failure hook now looks up the full key object from cache/DB using the key hash to populate the missing fields. 2. Post-auth failures (provider errors, rate limits): key fields are present but team_alias is always null because LiteLLM_VerificationTokenView SQL view does not include team_alias. The failure hook now looks up the team object from cache to populate team_alias. Both lookups are non-fatal and wrapped in try/except. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>