From 79e575403f24df066177596ac74d8442d5e392b4 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sat, 28 Feb 2026 04:45:10 +0000 Subject: [PATCH] fix(router): use string id in test_add_deployment and add defensive str() in register_model - Change test to use string '100' instead of int 100 for model_info.id - Add str() conversion in register_model to prevent AttributeError on non-string keys Co-authored-by: Ishaan Jaff --- litellm/utils.py | 3 ++- tests/router_unit_tests/test_router_helper_utils.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/litellm/utils.py b/litellm/utils.py index 81e772b1765..02fb346bba9 100644 --- a/litellm/utils.py +++ b/litellm/utils.py @@ -2765,8 +2765,9 @@ def register_model(model_cost: Union[str, dict]): # noqa: PLR0915 for key, value in loaded_model_cost.items(): ## get model info ## provider = value.get("litellm_provider", "") + _key_str = str(key) if provider in _skip_get_model_info_providers or any( - key.startswith(f"{p}/") for p in _skip_get_model_info_providers + _key_str.startswith(f"{p}/") for p in _skip_get_model_info_providers ): existing_model = litellm.model_cost.get(key, {}) model_cost_key = key diff --git a/tests/router_unit_tests/test_router_helper_utils.py b/tests/router_unit_tests/test_router_helper_utils.py index 99926b39c9f..3001aec8b86 100644 --- a/tests/router_unit_tests/test_router_helper_utils.py +++ b/tests/router_unit_tests/test_router_helper_utils.py @@ -807,7 +807,7 @@ def test_add_deployment(model_list): deployment = router.get_deployment_by_model_group_name( model_group_name="gpt-3.5-turbo" ) - deployment["model_info"]["id"] = 100 + deployment["model_info"]["id"] = "100" ## Test 1: call user facing function router.add_deployment(deployment=deployment)