Files
litellm/tests/test_litellm/proxy/hooks
yuneng-jiang f4e23c97fd [Fix] Enrich failure spend logs with key/team metadata
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>
2026-02-24 17:14:37 -08:00
..