revert: undo teamless all-team-models denial from #32022 and #29746 - #32032
Conversation
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
|
|
Greptile SummaryThis PR reverts the "teamless all-team-models denial" introduced in #29746 and partially re-introduced in #32022, restoring the original behavior where a key configured with
Confidence Score: 5/5Safe to merge — the change is a targeted revert of a regression with no net new auth surface opened beyond the pre-#29746 baseline. All three production call sites are changed consistently, the old denial tests have been correctly renamed and their assertions flipped, and six focused regression tests now guard each auth surface. The empty-list unrestricted semantics in No files require special attention.
|
| Filename | Overview |
|---|---|
| litellm/proxy/auth/auth_checks.py | Reverts two changes from #32022: _resolve_key_models_for_auth_check now returns [] (unrestricted) for teamless all-team-models keys, and can_key_call_resolved_model drops the team_id is not None guard from skip_key_model_check, restoring pre-#29746 behavior. |
| litellm/proxy/auth/model_checks.py | Removes the team_id is not None guard in get_key_models so teamless all-team-models keys expand the sentinel to team_models (which is [] for teamless keys), yielding unrestricted access and matching pre-#29746 behavior. |
| litellm/proxy/auth/user_api_key_auth.py | Removes the team_id is not None guard from _enforce_key_and_fallback_model_access, allowing teamless all-team-models keys to skip the key-level model check (and fallback validation) via the pass branch. |
| tests/test_litellm/proxy/auth/test_auth_checks.py | Renames and inverts the old denial tests to assert the new unrestricted behavior; adds test_resolve_key_models_teamless_all_team_models_returns_empty and test_can_key_call_resolved_model_teamless_all_team_models_passes as regression guards. |
| tests/test_litellm/proxy/auth/test_model_checks.py | Adds test_get_key_models_teamless_all_team_models_returns_unrestricted to guard the get_key_models change; test correctly asserts an empty list is returned for a teamless key with the sentinel. |
| tests/test_litellm/proxy/hooks/test_batch_file_validation.py | Adds test_pre_call_allows_teamless_all_team_models_key to guard the batch path; correctly patches llm_router and calls _enforce_batch_file_model_access without mocking the auth functions themselves. |
Reviews (5): Last reviewed commit: "chore: retrigger checks" | Re-trigger Greptile
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Reverts the team_id guard in _resolve_key_models_for_auth_check and get_key_models so teamless keys with all-team-models resolve to [] (unrestricted = all proxy models) rather than being denied. Adds hardened regression tests across listing (get_key_models), inference (_enforce_key_and_fallback_model_access, can_key_call_model, can_key_call_resolved_model), and batch (_enforce_batch_file_model_access) paths that enforce teamless all-team-models == all-proxy-models and will fail if anyone re-introduces a team_id guard Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
89f8021 to
c58683e
Compare
|
Generated by Claude Code |
|
Generated by Claude Code |
|
bugbot run Generated by Claude Code |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 8181cc0. Configure here.
revert(auth): backport the teamless all-team-models denial revert (#32032) to 1.91.0rc1
…erriAI#29746 (BerriAI#32032) (cherry picked from commit 5ece78f)
Relevant issues
Reverts #32022 and the teamless denial introduced in #29746
Linear ticket
Pre-Submission checklist
@greptileaiand received a Confidence Score of at least 4/5 before requesting a maintainer reviewScreenshots / Proof of Fix
The prod code changes restore the original behavior where a teamless key with
models=["all-team-models"]is treated as unrestricted (equivalent to leaving models empty). The regression tests cover all four auth surfaces: listing (get_key_models), inference (_enforce_key_and_fallback_model_access,can_key_call_model,can_key_call_resolved_model), and batch (_enforce_batch_file_model_access)Type
🐛 Bug Fix
✅ Test
Changes
Prod code
_resolve_key_models_for_auth_check(auth_checks.py): returns[](unrestricted) for teamless keys instead of["all-team-models"](which caused denial since no real model matches the sentinel)get_key_models(model_checks.py): removes theteam_id is not Noneguard so teamless all-team-models resolves toteam_models->[](unrestricted), matching the pre-#29746 behaviorBoth changes from #32022 (
user_api_key_auth.pyandauth_checks.pycan_key_call_resolved_model) are also reverted (from the first commit on this branch)Hardened regression tests
Six new tests that will fail if someone re-introduces a team_id guard on the teamless all-team-models path:
test_resolve_key_models_teamless_all_team_models_returns_empty-- asserts_resolve_key_models_for_auth_checkreturns[]test_can_key_call_model_all_team_models_no_team_id_is_unrestricted-- assertscan_key_call_modelallows any model (replaces the old "is_denied" test)test_enforce_key_access_teamless_all_team_models_passes-- asserts_enforce_key_and_fallback_model_accessdoes not raisetest_can_key_call_resolved_model_teamless_all_team_models_passes-- assertscan_key_call_resolved_modelskips the key model check (mock is never awaited)test_get_key_models_teamless_all_team_models_returns_unrestricted-- assertsget_key_modelsreturns[]test_pre_call_allows_teamless_all_team_models_key-- asserts batch validation does not raiseLink to Devin session: https://app.devin.ai/sessions/68804be8677b4a0c9033e7c2663281bc
Requested by: @mateo-berri
Note
Medium Risk
Changes virtual-key model authorization semantics for teamless
all-team-modelskeys (broader access than the reverted denial); touches multiple auth hot paths including batch validation.Overview
Reverts the teamless
all-team-modelsdenial from #32022 / #29746 so API keys withmodels=["all-team-models"]and noteam_idbehave like an empty models list again (unrestricted proxy model access), not a hard deny.Auth resolution:
_resolve_key_models_for_auth_checknow returns[]for teamless keys (instead of leaving the sentinel, which never matched a real model).get_key_modelsexpands the sentinel without requiringteam_id.Inference paths: Key-level checks are skipped whenever
all-team-modelsis present—including teamless keys—incan_key_call_resolved_modeland_enforce_key_and_fallback_model_accessinuser_api_key_auth.py.Tests: Denial expectations are flipped to allow/skip-check behavior, with regression tests across listing, inference, resolved-model, and batch file validation.
Reviewed by Cursor Bugbot for commit 8181cc0. Bugbot is set up for automated code reviews on this repo. Configure here.