fix(ui/add-model): stop vertex_ai-anthropic_models from leaking into Anthropic dropdown (LIT-3311) - #29051
Conversation
…ui/litellm-dashboard/src/components/provider_info_helpers.tsx
…ui/litellm-dashboard/src/components/provider_info_helpers.test.tsx
|
|
Greptile SummaryThis PR fixes a provider model leak in the Add Model UI by replacing a broad
Confidence Score: 5/5The change is a minimal, pure helper function fix with no backend or auth impact; safe to merge. The two-line logic change is tightly scoped to a single pure function, the rewritten and new tests directly cover the regression and all named provider families, and the fix correctly preserves the existing inclusive semantics (e.g. bedrock_converse still appears under Bedrock, vertex_ai-anthropic_models still appears under Vertex_AI). No files require special attention.
|
| Filename | Overview |
|---|---|
| ui/litellm-dashboard/src/components/provider_info_helpers.tsx | Replaces broad .includes() substring match with separator-anchored startsWith() in getProviderModels, correctly stopping vertex_ai-anthropic_models from leaking into the Anthropic dropdown. |
| ui/litellm-dashboard/src/components/provider_info_helpers.test.tsx | Rewrites one previously-incorrect test and adds six new targeted regression tests for the prefix-anchor fix, including leak-guard tests for Vertex_AI/Anthropic and Vertex_AI/OpenAI cross-contamination. |
Reviews (1): Last reviewed commit: "fix(ui/add-model): stop vertex_ai-anthro..." | Re-trigger Greptile
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
What
getProviderModelsinprovider_info_helpers.tsxmatched models against theselected provider with a substring
litellmProvider.includes(custom_llm_provider)check. With
custom_llm_provider = "anthropic", this matched any model whoselitellm_providerfield contained the substringanthropic— including the29
vertex_ai-anthropic_modelsentries inmodel_prices_and_context_window.json.The Add Model UI then surfaced all of those
vertex_ai/*Claude entries underthe Anthropic provider, which is what the ticket reports.
Fix
Replace the substring
.includes()match with a separator-anchored prefix match(
litellmProvider.startsWith(${custom_llm_provider}_)or...startsWith(${custom_llm_provider}-)).So:
anthropic-> matchesanthropic,anthropic_text✓anthropic-> does NOT matchvertex_ai-anthropic_models✓vertex_ai-> still matchesvertex_ai,vertex_ai-anthropic_models,vertex_ai-text-models,vertex_ai_beta✓bedrock-> still matchesbedrock,bedrock_converse,bedrock_mantle✓fireworks_ai-> still matchesfireworks_ai,fireworks_ai-embedding-models✓This is the same fix that merged to
litellm_internal_stagingin #28723; thebug is still present on
litellm_oss_agent_shin_daily_branchbecause thatPR did not propagate.
Refs
LIT-3311
Evidence
The runtime surface for this bug is a pure helper in the dashboard JS bundle —
the model list under the Add Model -> Provider dropdown comes straight from
getProviderModels(provider, modelMap)(ModelsAndEndpointsView.tsx:158). Thehelper is fed the in-tree
model_prices_and_context_window_backup.json.The evidence below was captured by running the exact match logic against the
production model_cost_map data — the same data the dashboard receives in the
browser — once with the buggy
.includes()frommain, once with the fix onthis branch:
Why not a browser screenshot
The LiteLLM proxy could not be brought up in this sandbox: every
litellm-uprun failed at the Prismahealth_checkcall withprisma.engine.errors.EngineRequestError: 502: vault upstream:. With no proxy,the dashboard at
/ui/is not reachable, so I could not drive a real browserthrough Add Model -> Provider -> Anthropic. The Node-level reproduction above
exercises the same code path the UI runs (the helper is a single pure function
imported from the dropdown view) against the same data, so it is the same
behavioral capture, just one frame inboard of the rendered
<Select />.Tests
ui/litellm-dashboard/src/components/provider_info_helpers.test.tsx— 52/52passed under
vitest. New tests added on top of the existing suite:should not leak vertex_ai-anthropic_models into the Anthropic providershould not leak vertex_ai-openai_models into the OpenAI providershould include all vertex_ai variants when called with 'Vertex_AI' provider keyshould include bedrock variants (converse, mantle) when called with 'Bedrock' provider keyshould include fireworks_ai-embedding-models when called with 'FireworksAI' provider keyshould return models when litellm_provider includes the provider stringtest was renamed and rewritten to assert prefix-anchor semantics on Anthropic, since the old substring assertion would not have caught this bug.Note on push path
Used the GitHub Contents API (
PUT /repos/.../contents/{path}) because thecurrent
GITHUB_TOKENlacksrepo+workflowscopes sogit push403s with"Password authentication is not supported." Two commits, one per file —
reviewers may want to view them squashed.
Session: https://litellm-agent-platform.onrender.com/sessions/5d8e9bcd-a9b7-406b-b299-23d3f106bee3
Verification (ship-pr)
ui/litellm-dashboard/src/components/provider_info_helpers.tsx— pure helper used by the Add Model UI dropdownui/litellm-dashboard/src/components/provider_info_helpers.test.tsx— vitest testsmodel_prices_and_context_window_backup.json)prisma.engine.errors.EngineRequestError: 502: vault upstream:, so the/ui/dashboard was unreachable. The Node-level reproduction in the Evidence section runs the same pure helper imported byModelsAndEndpointsView.tsx:158against the same data the UI receives.model_prices_and_context_window_backup.jsonshipped with this branch. Vitest run (npx vitest run src/components/provider_info_helpers.test.tsx) reportedTest Files 1 passed (1) | Tests 52 passed (52).