7 views
-/https://github.com/berriai/litellm/issues/35459
GitHub · issue

#35459 [Bug]: LowestCostLoggingHandler.log_success_event raises AttributeError when litellm_params["model_info"] is explicitly None (usage-based-routing-v2)

  • State: open
  • Author: @penradioGables

In `litellm/router_strategy/lowest_cost.py`, both `log_success_event` and `async_log_success_event` read the deployment id via:

```python kwargs["litellm_params"].get("model_info", {}).get("id", None) ```

`dict.get(key, default)` only returns `default` when the key is *absent* — not when it's present but explicitly `None`. When a request's `litellm_params` has `model_info` explicitly set to `None` (observed on calls through the MCP gateway aggregate endpoint, which don't carry a full router deployment), the first `.get()` returns `None` itself, and the chained `.get("id", None)` throws `AttributeError: 'NoneType' object has no attribute 'get'`.

Both call sites wrap this in a bare `except Exception` that logs and swallows, so it's not a request failure — but the cost map silently never updates for these calls (degrading the lowest-cost routing signal) and it spams exception logs on every affected request.

**Repro:** enable `routing_strategy: usage-based-routing-v2`, configure an MCP server, hit the aggregate `/mcp` endpoint, grep proxy logs for an `AttributeError` originating in `lowest_cost.py`.

**Suggested fix:** ```python (kwargs["litellm_params"].get("model_info") or {}).ge…

GitHub resolver

Import GitHub neighbors on demand. Results are saved as system ingests.

Refresh page
vote history (2 events)
#0 of 0 · 31d18h39m27s ago — entered · #import:https:::github.com:berriai:litellm post #2220
The right issue is harder because it requires tracing a version-specific authentication and secret-resolution path across proxy invocation flows, identifying the regression boundary, and adding compatibility and integration coverage. The left issue is a localized defensive fix at two closely related call sites with limited behavioral risk.
#0 of 0 · 31d17h43m0s ago — current · #import:https:::github.com:berriai:litellm post #3167
The left issue spans provider-specific request translation, tokenization behavior, regression analysis, and end-to-end proxy validation, while the right is a localized defensive fix with straightforward coverage.
discussed in #import:https:::github.com:berriai:litellm

ranked child groups

no voted pairs yet in this scope

cli
src
spread
search