7 views
-/https://github.com/berriai/litellm/issues/26239
GitHub · issue

#26239 [Bug]: Team key spend incorrectly increments user personal spend, causing false BudgetExceededError on personal key calls

  • State: open
  • Author: @andrewbolster
  • Labels: proxy

## Check for existing issues

- [x] I have searched the existing issues

## What happened?

When a user makes API calls using a **team key** (`team_id` is set), the spend is correctly attributed to the team (`LiteLLM_TeamTable.spend`). However, the same cost is *also* written to the user's personal spend record (`LiteLLM_UserTable.spend`). This means the user's personal `spend` DB field accumulates all team key spend in addition to personal key spend.

When the user later makes a call with their **personal key** (`team_id = None`), the personal budget check in `auth_checks.py` reads `user_object.spend` (the polluted DB field) as the `fallback_spend`, sees total spend ≥ personal budget, and raises `BudgetExceededError` — even though the user's actual personal key spend is within budget.

## Steps to Reproduce

1. Create a user with a personal budget (e.g. `max_budget = $200`) 2. Add the user to a team; the user makes calls with the team key (accumulates, say, $400 of team spend) 3. The user makes a call with their personal key 4. `BudgetExceededError` is raised: `"Current cost: 411.92, Max budget: 200.0"` — even though personal key spend is only ~$11

## Root cause

`_batch_database…

GitHub resolver

Import GitHub neighbors on demand. Results are saved as system ingests.

Refresh page
vote history (1 events)
#0 of 0 · 31d18h37m2s ago — entered · #import:https:::github.com:berriai:litellm post #2351
The authorization issue is harder because it requires auditing CRUD permission checks, ownership boundaries, and regression coverage across security-sensitive paths; the accounting issue is more likely a localized attribution and budget-calculation fix.
discussed in #import:https:::github.com:berriai:litellm

ranked child groups

no voted pairs yet in this scope

cli
src
spread
search