fix(proxy): populate access_via_team_ids on /v1/model/info - #30274
Conversation
bf68644 to
8ec8420
Compare
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Greptile SummaryThis PR populates
Confidence Score: 5/5Safe to merge — all changes are additive, default behavior is preserved, and the no-DB guard is correctly placed before any model-list work. Access-field population mutates a deep-copied model list so the router state is never touched; enrichment uses if-not-present semantics so populated fields survive the pipeline; the no-DB guard fires before the litellm_model_id branch; seven new tests cover the happy path, fail-fast paths, and single-model filtering. No files require special attention.
|
| Filename | Overview |
|---|---|
| litellm/proxy/proxy_server.py | Refactors get_all_team_and_direct_access_models into two focused helpers, adds include_team_models/teamId query params to /v1/model/info, and populates access fields on the v1 response whenever a DB is connected. |
| tests/test_litellm/proxy/proxy_server/test_team_model_name_translation.py | Adds seven new tests covering access-field population, no-DB fast-fail paths, and single-model-lookup filtering. Modified test preserves its core BYOK-hiding assertion. |
| ui/litellm-dashboard/src/lib/http/schema.d.ts | Generated OpenAPI schema updated to reflect the two new query parameters on /v1/model/info. |
Reviews (8): Last reviewed commit: "fix(proxy): apply teamId/include_team_mo..." | Re-trigger Greptile
Team metadata enrichment previously only ran on /v2/model/info with include_team_models=true, leaving /v1/model/info without access_via_team_ids for project model-picker flows. Co-authored-by: Cursor <cursoragent@cursor.com>
8ec8420 to
dfbab84
Compare
Add include_team_models and teamId to the generated schema for /model/info and /v1/model/info after the proxy endpoint gained team-access filtering. Co-authored-by: Cursor <cursoragent@cursor.com>
Set direct_access to true or false on every enriched model so clients can filter without treating a missing field as ambiguous. Co-authored-by: Cursor <cursoragent@cursor.com>
…v1/model/info Raise the db_not_connected error before building, enriching, and translating the model list instead of after, so a teamId query against a proxy with no database no longer wastes the full enrichment pipeline.
…itellm_v1_model_info_team_access
include_team_models=True relies on _populate_team_access_on_models to set direct_access/access_via_team_ids, which only runs when a database is connected. Without one, _filter_models_to_user_accessible discarded every model and the endpoint returned an empty list with HTTP 200. Mirror the teamId guard so the request fails fast with a clear db_not_connected error before any model-list work.
The /v1/model/info list path populates model_info.direct_access (and access_via_team_ids) when a database is connected, but the litellm_model_id single-model lookup returned early without it. This made the two endpoints disagree, breaking the parity assertion in test_get_specific_model. Run the same population on the single-model path so both responses match.
The teamId/include_team_models no-DB guard sat after the litellm_model_id early return, so ?litellm_model_id=X&teamId=Y with no DB returned 200 with unpopulated access fields instead of the 500 raised on every other path. Move the guard ahead of the branch so the fast-fail is uniform.
…lookup The litellm_model_id early-return branch in model_info_v1 populated the team access fields but returned before the teamId and include_team_models filters ran, so a single-model lookup surfaced the deployment regardless of team access when the DB was connected. Run both filters on the single-model list before returning so the documented query params behave the same with and without litellm_model_id.
Summary
model_info.access_via_team_idsandmodel_info.direct_accessonGET /v1/model/infowhen the proxy database is connectedinclude_team_modelsandteamIdquery params to/v1/model/infofor parity with/v2/model/info_populate_team_access_on_modelsTest plan
poetry run pytest tests/test_litellm/proxy/proxy_server/test_team_model_name_translation.py -qpoetry run pytest tests/test_litellm/proxy/proxy_server/test_team_model_name_translation.py::test_model_info_v1_populates_access_via_team_ids -vcurl /v1/model/inforeturnsaccess_via_team_idsper model