litellm/tests/litellm_utils_tests
ryan-crabbe-berri 760043b533 fix(reset_budget_job): reset end users by budget link, not by user id
The cascade zeroed end-user spend with a single update_many whose where
clause enumerated every dependent user id. Prisma compiles that IN-list
into one prepared statement carrying one bind variable per customer, and
PostgreSQL caps a statement at 32,767 of them. Once a shared budget had
more dependents than that the statement could not be parsed at all, so
the atomic cascade rolled back, budget_reset_at never advanced, and the
tier stayed due on every later tick forever. Customers sitting at their
cap were blocked indefinitely with only a recurring log line to show for
it.

End users now match on budget_id like every other gated table, plus a
NULL-budget_id branch for the implicitly created rows that carry no link
and ride the default tier. The statement's bind count now tracks the
number of expiring tiers rather than the customer population, so a reset
costs the same whether a budget has ten dependents or a million.

Fixes #40564

Claude-Session: https://claude.ai/code/session_01Hn5E8Jz1LjGLFyiYxBRcBW
2026-09-10 16:57:53 -07:00
..
base_token_counter_test.py
conftest.py
log.txt
test_aiohttp_handler.py
test_anthropic_token_counter.py
test_aws_secret_manager.py
test_azure_ai_anthropic_token_counter.py
test_bedrock_token_counter.py
test_cyberark.py
test_get_secret.py
test_hashicorp.py
test_health_check.py
test_litellm_overhead.py
test_logging_callback_manager.py
test_proxy_budget_reset.py fix(reset_budget_job): reset end users by budget link, not by user id 2026-09-10 16:57:53 -07:00
test_secret_manager.py
test_utils.py
test_validate_tool_choice.py
vertex_key.json