Fix team max budget check to block at exact budget (>= instead of >)#28109
Conversation
Greptile SummaryThis PR fixes an off-by-one bug in the team budget enforcement path:
Confidence Score: 5/5Safe to merge — the change is a one-character correction that closes a gap between the team budget check and every other budget check in the same file, with a targeted regression test covering the exact boundary case. The fix is minimal and surgical: a single No files require special attention.
|
| Filename | Overview |
|---|---|
| litellm/proxy/auth/auth_checks.py | One-character fix: > → >= in _team_max_budget_check so teams are blocked when spend exactly equals max_budget, consistent with all other budget checks in the file. |
| tests/test_litellm/proxy/auth/test_auth_checks.py | Adds a regression test test_team_budget_check_blocks_when_spend_equals_max_budget that mocks get_current_spend to return exactly max_budget and asserts BudgetExceededError is raised — no real network calls. |
Reviews (4): Last reviewed commit: "Fix team max budget check to block at ex..." | Re-trigger Greptile
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
69f28fd to
8cb8c96
Compare
|
@greptileai retrigger on latest commit |
|
🤖 litellm-agent: Auto-merge skipped — the staging branch Please rebase your branch onto |
8cb8c96 to
0e4df2d
Compare
|
@greptileai please retrigger on rebased commit |
Aligns _team_max_budget_check with the >= comparator used by _virtual_key_max_budget_check, key budget windows, team budget windows, team member budget, team soft budget, and org budget. Previously a team whose spend exactly matched its max_budget was allowed through, while a key with the same spend/budget was correctly blocked. Fixes BerriAI#28020
0e4df2d to
8abe074
Compare
|
@greptileai please retrigger on rebased commit |
Relevant issues
Fixes #28020
Type
🐛 Bug Fix
Changes
_team_max_budget_checkusedspend > team_object.max_budget, while everyother budget check in
auth_checks.py(key, key budget window, team budgetwindow, team member, team soft, org) uses
>=. As a result, a team whosespend exactly matched its
max_budgetwas allowed through, but a key inthe same state was correctly blocked.
This PR changes the team check to
>=for consistency. Added a regressiontest in
tests/test_litellm/proxy/auth/test_auth_checks.pythat assertsBudgetExceededErroris raised whenspend == max_budget.Pre-Submission checklist
tests/test_litellm/proxy/auth/test_auth_checks.pytests/test_litellm/proxy/auth/test_auth_checks.pypasses locally (117 passed)