litellm/tests/test_litellm/router_strategy
Ishaan Jaffer 8fcda9083f fix(tag_regex): address backwards-compat, metadata overwrite, and warning noise
Three issues from code review:

1. Backwards-compat: `has_tag_filter` was widened to activate on any non-empty
   User-Agent, which would raise ValueError for existing deployments using plain
   tags without a `default` fallback. Fix: only activate header-based regex
   filtering when at least one candidate deployment has `tag_regex` configured.

2. Metadata overwrite: `metadata["tag_routing"]` was overwritten for every
   matching deployment in the loop, leaving inaccurate provenance when multiple
   deployments match. Fix: write only for the first match.

3. Warning noise: an invalid regex pattern logged one warning per header string
   rather than once per pattern. Fix: compile first (catching re.error once),
   then iterate over header strings.

Also adds two new tests covering these cases, and adds docs page for
tag_regex routing with a Claude Code walk-through.
2026-03-13 17:55:47 -07:00
..
test_auto_router.py fix mapped test 2025-07-25 07:24:42 -07:00
test_base_routing_strategy.py Simplify experimental multi-instance rate limiter - more accurate (#11424) 2025-06-07 11:10:55 -07:00
test_budget_limiter_hotpath.py fix(router): remove repeated provider parsing in budget limiter hot path (#21043) 2026-02-12 20:05:55 -08:00
test_complexity_router.py fix: complexity_router crashes on list-format message content (OpenAI multi-part messages) (#22761) 2026-03-04 16:18:49 -08:00
test_router_tag_regex_routing.py fix(tag_regex): address backwards-compat, metadata overwrite, and warning noise 2026-03-13 17:55:47 -07:00
test_router_tag_routing.py feat(tag-routing): support toggling tag matching between ANY and ALL (#18776) 2026-01-08 23:39:03 +05:30