litellm/tests/router_unit_tests
FlibbertyGibbitz 3f4a9d8d08
fix(router): Validate routing_strategy at startup to fail fast with helpful error. (#18624)
Invalid routing_strategy values (e.g., "simple" instead of "simple-shuffle") previously failed silently, causing confusing "No deployments available" errors downstream. This change adds upfront validation in routing_strategy_init() to:

- Check if the provided strategy matches valid string values or RoutingStrategy enum
- Raise a clear ValueError listing valid options if invalid
- Fail fast at startup instead of at request time

Fixes behavior reported in #11330 where users had to debug cryptic errors.

Valid strategies: simple-shuffle, least-busy, usage-based-routing, latency-based-routing, cost-based-routing, usage-based-routing-v2

Co-authored-by: Flibbert E. Gibbitz <flibbertygibbitz@runelabs.ai>
2026-01-06 01:22:09 +05:30
..
conftest.py [Perf] Improvements for Async Success Handler (Logging Callbacks) - Approx +130 RPS (#13905) 2025-08-23 13:13:23 -07:00
create_mock_standard_logging_payload.py
gettysburg.wav
README.md
test_completion_no_copy.py [Perf] Alexsander fixes round 2 - Oct 18th (#15695) 2025-10-18 11:12:00 -07:00
test_default_deployment_copy.py [Perf] Alexsander fixes round 2 - Oct 18th (#15695) 2025-10-18 11:12:00 -07:00
test_pre_call_checks_optimization.py [Perf] Alexsander fixes round 2 - Oct 18th (#15695) 2025-10-18 11:12:00 -07:00
test_prompt_management_check.py [Perf] Alexsander fixes round 2 - Oct 18th (#15695) 2025-10-18 11:12:00 -07:00
test_router_adding_deployments.py
test_router_batch_utils.py fix(batch_utils.py): improve batch utils to handle newlines within batch content 2025-11-05 16:15:09 -08:00
test_router_cooldown_utils.py fix(router): add minimum request threshold for error rate cooldown (#17464) 2025-12-12 04:36:10 -08:00
test_router_endpoints.py [Fix] Containers API - Allow using LIST, Create Containers using custom-llm-provider (#17740) 2025-12-09 17:00:35 -08:00
test_router_handle_error.py fix(handle_error.py): add unit tests 2025-08-11 18:25:30 -07:00
test_router_helper_utils.py fix(router): Validate routing_strategy at startup to fail fast with helpful error. (#18624) 2026-01-06 01:22:09 +05:30
test_router_index_management.py [Oct Staging Branch] (#15460) 2025-10-17 17:52:25 -07:00
test_router_prompt_caching.py [Fix] - Router's Cache: Fix routing for requests with same cacheable prefix but different user messages (#16951) 2025-11-21 19:13:40 -08:00

Router component unit tests.

Please name all files with the word 'router' in them.

This is used to ensure all functions in the router are tested.