Skip to content

fix(proxy): restore wildcard expansion in /v1/model/info - #31444

Merged
mateo-berri merged 6 commits into
litellm_internal_stagingfrom
litellm_model_info_wildcard_expansion
Jun 26, 2026
Merged

fix(proxy): restore wildcard expansion in /v1/model/info#31444
mateo-berri merged 6 commits into
litellm_internal_stagingfrom
litellm_model_info_wildcard_expansion

Conversation

@Sameerlite

@Sameerlite Sameerlite commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds expand_wildcard_deployments_for_model_info() to model_checks.py that fans out wildcard deployments (e.g. openai/*, *) into one row per known provider model, restoring the behaviour users expected.
  • The expansion is applied only to the /v1/model/info endpoint (model_info_v1). /v2/model/info is unchanged.
image

Note

Medium Risk
Touches model listing and permission filtering for a widely used admin/API endpoint; logic is defensive but expansion can increase response size for broad wildcards.

Overview
Restores wildcard fan-out on /v1/model/info after deployments started coming from llm_router.model_list (which fixed team-scoped rows but dropped per-model expansion).

Adds expand_wildcard_deployments_for_model_info(), which duplicates wildcard deployment dicts into one row per known provider model (via get_known_models_from_wildcard), aligned with /v1/models. /v2/model/info is unchanged.

Expansion picks the wildcard from model_name vs litellm_params.model so a concrete alias is not replaced when only the backend model is wildcarded; invalid LiteLLM_Params or empty expansions pass through unchanged to avoid errors.

Unit tests cover passthrough, openai/* expansion, alias preservation, and bad params.

Reviewed by Cursor Bugbot for commit c00185b. Bugbot is set up for automated code reviews on this repo. Configure here.

Sameerlite and others added 2 commits June 26, 2026 17:03
PR #30025 aligned /model/info with llm_router.model_list, which dropped
wildcard expansion. Add expand_wildcard_deployments_for_model_info() in
model_checks.py and call it in model_info_v1 so that wildcard deployments
(e.g. openai/*) are fanned out into individual model rows, matching
/v1/models behaviour. /v2/model/info is unchanged.

Co-authored-by: Cursor <cursoragent@cursor.com>
CI runs ruff format --check on changed files, not black.

Co-authored-by: Cursor <cursoragent@cursor.com>
@greptile-apps

greptile-apps Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Restores wildcard fan-out on /v1/model/info by introducing expand_wildcard_deployments_for_model_info() in model_checks.py, called once per request before the permission filter. /v2/model/info is unchanged.

  • Wildcard deployments (e.g. model_name=\"*\" / litellm_params.model=\"openai/*\") are fanned out into one row per known provider model, matching the behaviour of /v1/models; the branch ordering ensures a concrete alias model_name is never overwritten.
  • LiteLLM_Params construction is wrapped in try/except, and empty-expansion cases pass through unchanged, making the function fully defensive against unusual stored params.
  • Four unit tests and one integration test cover the main scenarios (passthrough, openai/* expansion, alias preservation, invalid params).

Confidence Score: 5/5

The change is additive and fully defensive — empty expansions and bad params both fall through unchanged — with no modifications to existing auth or routing logic.

The core expansion logic is correctly ordered and guarded; the only open items are a minor documentation gap in one test and a note about downstream dict-vs-object reads for expanded rows, neither of which affects runtime behaviour today.

No files require special attention; the integration test in test_routes_model_info.py only exercises unrestricted users, so restricted-user coverage would be a worthwhile follow-up.

Important Files Changed

Filename Overview
litellm/proxy/auth/model_checks.py Adds expand_wildcard_deployments_for_model_info with well-ordered branching logic, defensive try/except around LiteLLM_Params construction, and correct deepcopy of expanded rows.
litellm/proxy/proxy_server.py Single-line insertion of expand_wildcard_deployments_for_model_info call correctly placed before allowed_model_names filtering, so expansion is visible to the permission check.
tests/test_litellm/proxy/auth/test_model_checks.py Four new unit tests cover passthrough, openai/* expansion, alias preservation, and invalid-params passthrough; the invalid-params test has an implicit dependency on internal Pydantic coercion that should be documented.
tests/test_litellm/proxy/proxy_server/test_routes_model_info.py Integration test validates star-wildcard expansion survives the deployment filter for unrestricted users; restricted-user (team/key scoped) interaction is not tested.

Reviews (5): Last reviewed commit: "fix(proxy): fix reportUnknownArgumentTyp..." | Re-trigger Greptile

Comment thread litellm/proxy/auth/model_checks.py Outdated
Comment thread litellm/proxy/auth/model_checks.py Outdated
@codecov

codecov Bot commented Jun 26, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.89189% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
litellm/proxy/auth/model_checks.py 91.66% 3 Missing ⚠️

📢 Thoughts on this report? Let us know!

…ms errors

- Branch 2 of expand_wildcard_deployments_for_model_info now requires
  model_name to also be a wildcard before expanding via litellm_params.model,
  preventing concrete model_name values from being silently overwritten.
- Wrap LiteLLM_Params construction in try/except so invalid params fall
  through unchanged instead of raising a 500 on /v1/model/info.
- Add two tests covering the concrete-name + wildcard-params passthrough
  and the invalid-params passthrough paths.

Co-authored-by: Cursor <cursoragent@cursor.com>
@Sameerlite

Copy link
Copy Markdown
Contributor Author

@greptileai

Co-authored-by: Cursor <cursoragent@cursor.com>
@Sameerlite
Sameerlite force-pushed the litellm_model_info_wildcard_expansion branch from f791600 to c00185b Compare June 26, 2026 11:48
@Sameerlite

Copy link
Copy Markdown
Contributor Author

@greptileai

@Sameerlite

Copy link
Copy Markdown
Contributor Author

bugbot run

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Star wildcard rows dropped after filter
    • Expanded allowlists now use the provider wildcard from litellm_params when the public route is '*', so scoped model-info filters retain the concrete rows.

You can send follow-ups to the cloud agent here.

Reviewed by Cursor Bugbot for commit c00185b. Configure here.

Comment thread litellm/proxy/proxy_server.py
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ Sameerlite
❌ cursoragent
You have signed the CLA already but the status is still pending? Let us recheck it.

@Sameerlite

Copy link
Copy Markdown
Contributor Author

@greptileai

…nts_for_model_info

- Use model_validate() instead of **kwargs spread to avoid flooding basedpyright
  with one reportUnknownArgumentType per LiteLLM_Params field
- Use isinstance guard to narrow litellm_params_dict from Any to dict[str, Any]
- Use str() cast on model_name to eliminate partially-unknown argument violations

Co-authored-by: Cursor <cursoragent@cursor.com>
@Sameerlite

Copy link
Copy Markdown
Contributor Author

@greptileai

@Sameerlite
Sameerlite requested a review from mateo-berri June 26, 2026 12:30

@mateo-berri mateo-berri left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM; thanks!

@mateo-berri
mateo-berri merged commit 2b496bc into litellm_internal_staging Jun 26, 2026
123 checks passed
@mateo-berri
mateo-berri deleted the litellm_model_info_wildcard_expansion branch June 26, 2026 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants