fix: handle explicit None model_info in LowestLatencyLoggingHandler (#21633)

When model_info is explicitly set to None in litellm_params (via
get_litellm_params.py), the pattern .get("model_info", {}) returns
None instead of {}, causing AttributeError on the chained .get("id").

This commonly occurs when Anthropic API returns usage limit errors,
the router falls back to Vertex AI, and the fallback succeeds — the
log_success_event callback fires with model_info=None.

Uses the (x or {}) pattern already established in router.py.

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Darien Kindlund 2026-02-19 20:30:58 -05:00 committed by GitHub
parent d2bdf7d618
commit 0f2516e9cd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -52,7 +52,7 @@ class LowestLatencyLoggingHandler(CustomLogger):
"model_group", None
)
id = kwargs["litellm_params"].get("model_info", {}).get("id", None)
id = (kwargs["litellm_params"].get("model_info") or {}).get("id", None)
if model_group is None or id is None:
return
elif isinstance(id, int):
@ -204,7 +204,7 @@ class LowestLatencyLoggingHandler(CustomLogger):
"model_group", None
)
id = kwargs["litellm_params"].get("model_info", {}).get("id", None)
id = (kwargs["litellm_params"].get("model_info") or {}).get("id", None)
if model_group is None or id is None:
return
elif isinstance(id, int):
@ -273,7 +273,7 @@ class LowestLatencyLoggingHandler(CustomLogger):
"model_group", None
)
id = kwargs["litellm_params"].get("model_info", {}).get("id", None)
id = (kwargs["litellm_params"].get("model_info") or {}).get("id", None)
if model_group is None or id is None:
return
elif isinstance(id, int):