Skip to content

revert: undo teamless all-team-models denial from #32022 and #29746 - #32032

Merged
mateo-berri merged 3 commits into
litellm_internal_stagingfrom
litellm_revert-teamless-all-team-models-fix
Jul 4, 2026
Merged

revert: undo teamless all-team-models denial from #32022 and #29746#32032
mateo-berri merged 3 commits into
litellm_internal_stagingfrom
litellm_revert-teamless-all-team-models-fix

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Relevant issues

Reverts #32022 and the teamless denial introduced in #29746

Linear ticket

Pre-Submission checklist

  • I have added meaningful tests
  • My PR passes all CI/CD checks (e.g., lint, format, unit tests)
  • My PR's scope is as isolated as possible; it only solves 1 specific problem
  • I have requested a Greptile review by commenting @greptileai and received a Confidence Score of at least 4/5 before requesting a maintainer review

Screenshots / 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 the team_id is not None guard so teamless all-team-models resolves to team_models -> [] (unrestricted), matching the pre-#29746 behavior

Both changes from #32022 (user_api_key_auth.py and auth_checks.py can_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_check returns []
  • test_can_key_call_model_all_team_models_no_team_id_is_unrestricted -- asserts can_key_call_model allows any model (replaces the old "is_denied" test)
  • test_enforce_key_access_teamless_all_team_models_passes -- asserts _enforce_key_and_fallback_model_access does not raise
  • test_can_key_call_resolved_model_teamless_all_team_models_passes -- asserts can_key_call_resolved_model skips the key model check (mock is never awaited)
  • test_get_key_models_teamless_all_team_models_returns_unrestricted -- asserts get_key_models returns []
  • test_pre_call_allows_teamless_all_team_models_key -- asserts batch validation does not raise

Link 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-models keys (broader access than the reverted denial); touches multiple auth hot paths including batch validation.

Overview
Reverts the teamless all-team-models denial from #32022 / #29746 so API keys with models=["all-team-models"] and no team_id behave like an empty models list again (unrestricted proxy model access), not a hard deny.

Auth resolution: _resolve_key_models_for_auth_check now returns [] for teamless keys (instead of leaving the sentinel, which never matched a real model). get_key_models expands the sentinel without requiring team_id.

Inference paths: Key-level checks are skipped whenever all-team-models is present—including teamless keys—in can_key_call_resolved_model and _enforce_key_and_fallback_model_access in user_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.

@mateo-berri mateo-berri self-assigned this Jul 3, 2026
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@CLAassistant

CLAassistant commented Jul 3, 2026

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.

✅ mateo-berri
❌ devin-ai-integration[bot]
You have signed the CLA already but the status is still pending? Let us recheck it.

@greptile-apps

greptile-apps Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This 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 models=["all-team-models"] but no team_id is treated as unrestricted (equivalent to leaving models empty) rather than being denied access.

  • auth_checks.py: _resolve_key_models_for_auth_check returns [] for teamless all-team-models keys; can_key_call_resolved_model drops the team_id is not None guard from skip_key_model_check, so any all-team-models key bypasses the key-level check.
  • model_checks.py: get_key_models removes the team_id is not None guard so the sentinel expands to team_models ([] for teamless keys = unrestricted).
  • user_api_key_auth.py: _enforce_key_and_fallback_model_access removes the same guard from the all-team-models pass branch.
  • Six new regression tests cover all four auth surfaces (listing, inference, batch, and resolved-model) and will fail if someone re-introduces a teamless denial.

Confidence Score: 5/5

Safe 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 _can_object_call_model are confirmed by reading line 2844 (len(filtered_models) == 0 and len(models) == 0 → all_model_access = True), so the [] return from _resolve_key_models_for_auth_check correctly yields unrestricted access.

No files require special attention.

Important Files Changed

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

codecov Bot commented Jul 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

devin-ai-integration Bot and others added 2 commits July 4, 2026 00:34
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>
@devin-ai-integration
devin-ai-integration Bot force-pushed the litellm_revert-teamless-all-team-models-fix branch from 89f8021 to c58683e Compare July 4, 2026 00:42
@devin-ai-integration devin-ai-integration Bot changed the title revert: "fix(auth): deny model access for teamless keys with all-team-models (#32022)" revert: undo teamless all-team-models denial from #32022 and #29746 Jul 4, 2026
@mateo-berri

Copy link
Copy Markdown
Contributor

@greptileai


Generated by Claude Code

@mateo-berri mateo-berri closed this Jul 4, 2026
@mateo-berri mateo-berri reopened this Jul 4, 2026
@mateo-berri

Copy link
Copy Markdown
Contributor

@greptileai


Generated by Claude Code

@mateo-berri
mateo-berri marked this pull request as draft July 4, 2026 01:42
@mateo-berri
mateo-berri marked this pull request as ready for review July 4, 2026 01:42
@mateo-berri

Copy link
Copy Markdown
Contributor

bugbot run


Generated by Claude Code

@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.

✅ 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.

@mateo-berri
mateo-berri self-requested a review July 4, 2026 01:55

@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 5ece78f into litellm_internal_staging Jul 4, 2026
125 checks passed
@mateo-berri
mateo-berri deleted the litellm_revert-teamless-all-team-models-fix branch July 4, 2026 01:56
yuneng-berri added a commit that referenced this pull request Jul 4, 2026
revert(auth): backport the teamless all-team-models denial revert (#32032) to 1.91.0rc1
ap-anton-r-susilo pushed a commit to ap-anton-r-susilo/litellm that referenced this pull request Jul 6, 2026
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.

2 participants