Repository navigation
fix(proxy): expand all-proxy-models sentinel in direct access lookup - #31153
mateo-berri merged 2 commits into
Conversation
A user provisioned with "All Proxy Models" stores the literal "all-proxy-models" sentinel in user.models. get_direct_access_models looked that string up as a real model_name via get_model_list, which matched no deployment, so /v2/model/info marked every model direct_access=false and the Models + Endpoints page rendered empty for such users when they have no teams. The model dropdown / Playground worked because get_key_models already expands the sentinel to the full proxy model list, hence the inconsistency in the report. Expand the sentinel to all non-team deployment ids via get_model_ids(exclude_team_models=True), the same call the PROXY_ADMIN branch in the caller already uses. This fixes both /v1/model/info and /v2/model/info since they share _populate_team_access_on_models. Empty user.models stays "no direct access" to match get_key_models semantics. Fixes #22791
Greptile SummaryFixes a bug where internal users provisioned with the
Confidence Score: 5/5Safe to merge — the change is tightly scoped to one helper function and both affected endpoints, the fix reuses the exact same router call already trusted in the admin branch, and a The logic change is minimal and correct: the sentinel check is guarded by the existing Pydantic validator that coerces a DB NULL to [], so the No files require special attention.
|
| Filename | Overview |
|---|---|
| litellm/proxy/proxy_server.py | Expands the all-proxy-models sentinel in get_direct_access_models by returning llm_router.get_model_ids(exclude_team_models=True) when the sentinel is detected, matching the PROXY_ADMIN branch behavior; also refactors the non-sentinel path to an equivalent list comprehension. |
| tests/test_litellm/proxy/proxy_server/test_team_model_name_translation.py | Adds three new mock-only unit tests: sentinel expansion, explicit model name path, and a full integration-style chain through _populate_team_access_on_models → _filter_models_to_user_accessible for an internal user with no teams; no real network calls. |
Reviews (1): Last reviewed commit: "fix(proxy): expand all-proxy-models sent..." | Re-trigger Greptile
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
…itellm_fix_all_proxy_models_visibility
| direct_access_models: List[str] = [] | ||
| for model in user_db_object.models: | ||
| deployments = llm_router.get_model_list(model_name=model) | ||
| if deployments is not None: | ||
| for deployment in deployments: | ||
| model_id = deployment.get("model_info", {}).get("id", None) | ||
| if model_id is not None: | ||
| direct_access_models.append(model_id) | ||
| return direct_access_models | ||
| return [ | ||
| model_id | ||
| for model in user_db_object.models | ||
| for deployment in (llm_router.get_model_list(model_name=model) or []) | ||
| if (model_id := deployment.get("model_info", {}).get("id", None)) is not None | ||
| ] |
There was a problem hiding this comment.
wow this is way better. nice
e0c8a6b
into
litellm_internal_staging
Relevant issues
Fixes #22791
Linear ticket
Pre-Submission checklist
make test-unit@greptileaiand received a Confidence Score of at least 4/5 before requesting a maintainer reviewScreenshots / Proof of Fix
Repro: as an admin, create an internal user provisioned with "All Proxy Models" and no team, then list models as that user (the exact call the Models + Endpoints page makes).
Before this change the second call returns
total_count = 0(empty Models + Endpoints page) even though the same proxy has 37 models and the admin sees all 37. After the change the user sees the full set of non-team proxy models, matching what the Playground / model dropdown already showed (that path goes throughget_key_models, which already expands the sentinel, which is why the two views disagreed).verified locally:

Type
🐛 Bug Fix
Changes
A user provisioned with "All Proxy Models" stores the literal
all-proxy-modelssentinel inuser.models. On the read path behind/v1/model/infoand/v2/model/info,get_direct_access_modelslooped overuser.modelsand looked each entry up as a realmodel_nameviallm_router.get_model_list(model_name=...). The sentinel matches no deployment, so the lookup returned nothing, every model gotdirect_access=false, and with no team membership_filter_models_to_user_accessibledropped the entire list. The result was an empty Models + Endpoints page for exactly the users who were granted access to everything.The fix expands the sentinel to all non-team deployment ids via
get_model_ids(exclude_team_models=True), the same call thePROXY_ADMINbranch in the caller already uses. Because both/v1/model/infoand/v2/model/infoshare_populate_team_access_on_models, this fixes both. An emptyuser.modelsstill resolves to no direct access, matchingget_key_modelssemantics.Tests in
tests/test_litellm/proxy/proxy_server/test_team_model_name_translation.pycover the sentinel expansion inget_direct_access_models, the unchanged explicit-model path, and the full_populate_team_access_on_models->_filter_models_to_user_accessiblechain for an internal user with no teams; the chain test fails on the pre-fix code and passes after.