fix(proxy): resolve team wildcard credentials for vector store files - #33649
Conversation
Team-scoped wildcard deployments like openai/* are indexed separately from global router models, so vector store file requests failed with api_key=None when a team also had other yaml/db models. Pass team_id into credential lookup and consult team model indexes and pattern routers. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Shivam Rawat seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
Greptile SummaryThis PR fixes credential resolution for vector-store file endpoints when a team has both a team-scoped OpenAI wildcard (
Confidence Score: 5/5Safe to merge — the change is narrowly scoped to credential lookup for the vector-store files passthrough endpoint and adds explicit lifecycle cleanup for team pattern routers. The fix correctly threads team_id through both call sites in the endpoint, the three-step lookup in get_deployment_credentials_with_provider (exact team key then team pattern router then global pattern router) matches the intended priority order, and the team_pattern_routers reset/prune paths close the stale-credential window that existed before. The new tests exercise each of these paths without real network calls. No files require special attention.
|
| Filename | Overview |
|---|---|
| litellm/proxy/vector_store_files_endpoints/endpoints.py | Passes caller's team_id to both get_deployment_credentials_with_provider call sites so team-scoped wildcard credentials are resolved correctly |
| litellm/router.py | Extends get_deployment_credentials_with_provider with team_id lookup (exact key then team_pattern_routers), resets team_pattern_routers in set_model_list, and prunes stale entries on delete_deployment |
| litellm/router_utils/pattern_match_deployments.py | Adds remove_deployment method that correctly prunes deployments by model_info.id and drops patterns whose deployment list becomes empty |
| tests/test_litellm/test_router.py | Adds four regression tests covering team wildcard priority over global wildcard, stale credential access after delete, remove_deployment correctness, and upsert/set_model_list refresh; all are mock-only with no real network calls |
Reviews (2): Last reviewed commit: "test(router): cover PatternMatchRouter.r..." | Re-trigger Greptile
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
PR overviewAll previously flagged issues have been addressed. No open security concerns remain on this pull request. Security reviewNo open security issues remain on this pull request. Fixed/addressed: 1 · PR risk: 0/10 |
…r global patterns team_pattern_routers retained deleted/replaced deployments, so team users could keep resolving stale credentials; now set_model_list resets the registry and deployment removal prunes it. Also consult the team wildcard router before the global pattern_router in get_deployment_credentials_with_provider so a global pattern like "openai/*" no longer shadows the team's own entry Co-authored-by: Cursor <cursoragent@cursor.com>
…ode coverage gate Co-authored-by: Cursor <cursoragent@cursor.com>
|
@greptile review again with the new comments that resolve the p2 issues. |
Co-authored-by: Cursor <cursoragent@cursor.com> # Conflicts: # litellm/router.py
…itellm_list_vs_fil
…d kwarg Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Resolves LIT-3598
Issue
Vector store file requests (GET /v1/vector_stores/{id}/files) fail with invalid_api_key / api_key=None when a team has both a team-scoped OpenAI wildcard model (openai/) and other yaml/db models (e.g. Bedrock, Anthropic). The same request works when the team only has openai/
Cause
Team wildcard deployments like openai/* live in team-scoped router indexes (team_model_to_deployment_indices, team_pattern_routers), not the global router indexes. The vector store files endpoint resolves credentials via get_deployment_credentials_with_provider, which only checked global indexes, so it never found the team's openai/* deployment. With a single team model, a fallback set data["model"] and normal router routing still worked; with multiple team models that fallback was skipped and the request went to OpenAI without credentials
Fix
Add optional team_id to get_deployment_credentials_with_provider and fall back to team model indexes and team pattern routers when global lookup fails. Pass the caller's team_id from the vector store files endpoint into credential resolution so team wildcard OpenAI credentials are attached correctly
Review follow-ups: team_pattern_routers is now reset by set_model_list and pruned when a deployment is removed, so deleted or replaced team wildcard deployments can no longer serve stale credentials. Credential resolution also consults the team wildcard router before the global pattern router, so a global pattern like openai/* no longer shadows the team's own entry. Regression tests cover both in tests/test_litellm/test_router.py
Before:

After:
