litellm/tests/test_litellm/proxy/management_endpoints
devin-ai-integration[bot] f285229b51
fix(proxy): delete large teams without per-member transaction fan-out (#42998)
* fix(proxy): delete large teams without per-member transaction fan-out

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(proxy): evict email-only member caches and reset team members metric on delete

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(proxy): keep new delete-team literals within the LIT002 ceiling

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(proxy): resolve deleted-team member ids before the locked delete

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(proxy): resolve email-only deleted-team members with one case-insensitive lookup

`_deleted_team_member_user_ids` looked each email-only roster entry up with its own
`find_users_by_email` call inside an unbounded `asyncio.gather`: one exact-match query
per email, so a large roster fanned out against the pool again and a roster email that
differed in case from its user row was missed. Add `UserRepository.find_by_emails`, a
single case-insensitive `in` query, and call it once before the locked delete.
`management_helpers/utils.py` goes back to its main-branch shape since the single-email
helper no longer needs exporting.

* fix(repositories): slice find_by_emails into bounded IN statements

The unbounded-IN lint flagged the case-insensitive email lookup added for
/team/delete cache eviction. chunked_in.find_many_in cannot carry Prisma's
insensitive mode, so the repository slices the deduplicated list into
IN_LIST_CHUNK_SIZE statements itself and concatenates the pages. Empty input
still returns () without a query.

* fix(proxy): delete a team once when /team/delete repeats its id

The audit sent {"team_ids": [T, T]}: main answered 400 "User not found in
team" after deleting the keys and memberships and writing two tombstones,
leaving the team row behind; this branch answered 200 but still wrote the
tombstone, audit row and eviction twice. DeleteTeamRequest now collapses
repeated ids in order, so every later step sees each team once and the
response lists each deleted team once.

* test(integration): audit cells for /team/delete on large, legacy and concurrent teams

Thirty-eight deterministic cells in tests/integration/management/ (the CircleCI
integration-management group) covering the /team/delete happy, sad, edge and chaos rows:
250 members against a pool limit of five on two workers, the advisory-lock wait, email-only
legacy roster entries in every casing, member and team cache eviction on both proxies for
every client and endpoint, the Prometheus gauge, audit rows, malformed and duplicate input,
the route gate, and a worker kill, a Redis outage and a proxy restart mid-burst.

Every cell runs against the real proxy, Postgres and Redis with the scripted upstream; no
component is mocked. On the merge base the rows this fix changes are red (P2028 on the
250-member team, two lock waiters, case-mismatched email lookups, duplicate ids, orphaned
LiteLLM_UserTable.teams references under a concurrent burst); on the tip every cell is green
twice with identical selections.

Two pre-existing behaviours are pinned as observed rather than fixed here: a roster entry with
neither user_id nor user_email answers 500, and the LiteLLM_DeletedTeamTable row is committed
before the locked transaction, so a delete that dies in between leaves a tombstone for a live
team and the retry adds a second.

* test(integration): pin each chaos outage to a live /team/delete

The three chaos cells applied the outage once three deletes had answered, which on a fast
run let the whole burst finish before the worker kill, Redis stop or SIGTERM landed, so the
cells passed without exercising the failure. Each cell now holds the first team's advisory
lock from a test-owned transaction, waits until that team's delete is queued behind it in
Postgres with its request unanswered, applies the outage, and only then releases the lock,
so an in-flight delete meets the failure on every run and both legs. The pinned team's
outcome and the number of deletes answered before the outage are recorded as junit
properties (pinned_delete, answered_before_outage).

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: ryan-crabbe-berri <ryan@berri.ai>
2026-09-30 13:49:18 -07:00
..
management_v1 fix(team): keep a forked member budget's reset window and audit bulk member budget writes 2026-09-17 15:17:00 -07:00
policy_endpoints fix(registry): correct eu Claude 3.5 Haiku Bedrock pricing, add Nova v1 tool_choice, Azure gpt-5.5 snapshot retirement 2026-09-09 13:16:04 +00:00
scim fix(proxy): evict the cached user row when SCIM or /user/delete removes a user 2026-09-21 13:51:26 -07:00
search_endpoints fix(proxy): sync search tools into the router on management writes 2026-08-26 11:46:54 -07:00
sso feat(agents): authenticate Entra identities and delegated requests (#43722) 2026-09-30 13:05:22 -07:00
usage_endpoints fix(proxy): emit SSE keepalives on queue, rag, azure passthrough, usage chat and policy enrich streams (#39273) 2026-09-03 18:23:37 -07:00
jwt_key_mapping_doubles.py test(proxy): share the jwt key mapping test doubles across the deletion endpoint tests 2026-09-18 00:17:45 +00:00
test_access_group_endpoints.py feat(agents): attach access groups to agents and enforce them for models, MCP servers and agent calls 2026-09-17 19:24:14 +00:00
test_access_group_management.py test(budgets): cover management null handling 2026-09-16 21:42:55 -07:00
test_activity_tenant_scoping.py
test_auto_router_endpoints.py fix(autorouter): compare historical and new savings consistently (#43348) 2026-09-29 12:40:19 -07:00
test_budget_endpoints.py feat(proxy): add tpd_limit (tokens per day) for batch submissions 2026-09-13 10:06:07 +00:00
test_cache_settings_endpoints.py
test_callback_management_endpoints.py feat(langfuse): migrate the sdk callback to langfuse v4 (#36741) 2026-09-24 23:22:56 -07:00
test_common_daily_activity.py fix(proxy): recover session key owners from daily spend for usage attribution (#43642) 2026-09-29 15:36:09 -07:00
test_common_utils.py fix(proxy): gate disable_global_guardrails on keys and teams to proxy admins (#42699) 2026-09-23 18:03:02 -07:00
test_compliance_endpoints.py Revert "refactor(guardrails): rename scoped-out evaluation status from not_run to skipped" 2026-09-14 23:46:09 +00:00
test_config_override_endpoints.py feat(vault): add separate login and secret namespaces for HashiCorp Vault 2026-09-17 01:41:48 +00:00
test_coordination_redis_endpoints.py test: drop two inert type: ignore comments 2026-09-19 14:22:19 -07:00
test_cost_estimate_endpoint.py
test_cost_tracking_settings.py Merge pull request #41832 from BerriAI/litellm_lit_8111_cache_read_missing_rate 2026-09-18 10:56:25 -07:00
test_credential_migration.py fix(mcp): encrypt stored static headers and stdio environment (#40164) 2026-09-07 16:03:06 -07:00
test_customer_budget.py
test_customer_endpoints.py test(proxy): include temp budget fields in customer budget table fixture 2026-09-17 18:10:00 +00:00
test_delete_callbacks_endpoint.py
test_delete_verification_tokens_failed.py
test_encryption_endpoints.py
test_entraid_app_roles.py fix(ui_sso): resolve highest privilege Entra app role, not first in claim (#36728) 2026-08-27 10:26:45 -07:00
test_gateway_request_endpoints.py
test_id_jag_assertion_capture.py feat(mcp): warn when an oauth2_id_jag server outruns the SSO provider's assertion capture (#35394) 2026-09-05 12:43:09 -07:00
test_internal_user_endpoints.py revert: "feat(usage): search team keys beyond the top-N in the Team usage view (#42857)" (#43377) 2026-09-28 21:47:46 +00:00
test_key_management_endpoints.py fix(ui): keep MCP permissions visible after key, team and MCP server saves (#43810) 2026-09-29 22:49:20 -07:00
test_mcp_connector_import.py fix(mcp): harden connector import auth handling and registration 2026-08-29 13:41:22 -07:00
test_mcp_management_endpoints.py feat(agents): enforce authoritative agent permissions (#43721) 2026-09-30 11:11:37 -07:00
test_model_insights_endpoints.py refactor: clean up fresh tech debt from 2026-09-28 (#43674) 2026-09-29 02:15:12 -07:00
test_model_management_endpoints.py fix(proxy): validate model credential name only when it changes (#42701) 2026-09-23 07:34:32 -07:00
test_org_admin_team_access.py
test_organization_endpoints.py Merge pull request #41620 from BerriAI/litellm_team_member_temp_budget_increase 2026-09-18 11:38:34 -07:00
test_password_endpoints.py test: deflake fuzzy picker, breached-password HIBP, and MCP stdio timeout tests (rolling deflake 2026-09-22) (#42125) 2026-09-23 08:44:59 -07:00
test_policy_endpoints.py
test_project_org_authz.py feat(proxy): let team admins manage projects via team_admin_editable_team_fields 2026-09-19 01:02:50 +00:00
test_prompt_cache_prediction.py Revert "test: keep prompt cache prediction logic tests and drop only their price pins" 2026-09-18 00:40:38 +00:00
test_prompt_caching_requests.py feat(ui): show prompt caching requests and net savings 2026-09-19 18:27:38 -07:00
test_ptu_model_settings.py feat(router): limit heuristic_v2 auto-routers to one without the auto_router license feature (#39468) 2026-09-03 13:39:58 -07:00
test_router_settings_endpoints.py feat(router): add group-scoped priority routing strategy (#42378) 2026-09-22 13:09:38 -07:00
test_saml_sso.py fix(sso): resolve multi-valued role claims to the highest privilege role (#39480) 2026-09-02 22:44:17 -07:00
test_session_endpoints.py fix(proxy): revoke UI session tokens on logout and password change (#42463) 2026-09-23 10:31:38 +02:00
test_tag_management_endpoints.py test(budgets): avoid mutable fixture state 2026-09-16 22:06:31 -07:00
test_team_admin_field_permissions.py feat(proxy): let team admins update member key budgets when enabled (#42555) 2026-09-25 01:54:52 +00:00
test_team_callback_endpoints.py feat(arize): per-team success and error sampling rates for the Arize AX callback (#42383) 2026-09-22 11:21:40 -05:00
test_team_default_params.py refactor(proxy): make the config file win over the database 2026-09-18 01:28:21 -07:00
test_team_endpoints.py fix(proxy): delete large teams without per-member transaction fan-out (#42998) 2026-09-30 13:49:18 -07:00
test_team_model_alias_merge.py
test_tool_management_endpoints.py
test_ui_sso.py feat(agents): authenticate Entra identities and delegated requests (#43722) 2026-09-30 13:05:22 -07:00
test_workflow_management_endpoints.py