Commit graph

35576 commits

Author SHA1 Message Date
Yuneng Jiang
83529fb5dc
fix(docker): backport non-root Dockerfile build fixes from main
Brings Dockerfile.non_root and UI dependency files from main to fix
the node-gyp missing module error during npm install. Pins npm, pip,
and adds .npmrc supply-chain hardening.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-04 18:00:16 -07:00
Ryan Crabbe
6434010c2b
refactor(proxy): extract _apply_non_admin_alias_scope to fix PLR0915
Extracts the non-admin scoping logic from key_aliases into a helper to
bring the function under ruff's 50-statement limit. No behavior change.
2026-04-04 17:45:51 -07:00
Ryan Crabbe
cb099ee75c
fix(ui): add useInfiniteTeams hook needed by team_multi_select
Cherry-pick of team_multi_select.tsx imported useInfiniteTeams which
didn't yet exist on this stable patch branch. Ported the hook from main
(aea8e32048).
2026-04-04 17:44:40 -07:00
Ryan Crabbe
8a3dabb09f
fix(ui): require TPM or RPM when adding a per-model team rate limit
Previously, a row with a model selected but both limits blank was
silently dropped on save (neither model_tpm_limit nor model_rpm_limit
got the key), so the row disappeared on reload with no feedback.
Now the TPM field's validator blocks submission with "Set at least
one of TPM or RPM" when a row has a model but neither limit filled.
2026-04-04 17:19:01 -07:00
Ryan Crabbe
89f32e1d75
feat(ui): add per-model rate limits to team edit/info views
Exposes the backend's existing model_tpm_limit/model_rpm_limit fields
(which lived in team.metadata) through a new "Model-Specific Rate Limits"
form section on the team Settings tab. Limits round-trip through the
team-update API and render on the Overview card and Settings view.

Model picker is scoped to the team's currently-selected models (unfurls
wildcards, falls back to userModels for all-proxy-models / all-team-models).
2026-04-04 17:19:01 -07:00
Ryan Crabbe
976e4c889d
feat(ui): expose Azure Entra ID credential fields in provider form
Adds tenant_id, client_id, and client_secret to the Azure provider entry
in provider_create_fields.json so the credential add/edit modals and the
add-model form surface Service Principal auth as an alternative to api_key.
The Azure handler already reads these fields from litellm_params at request
time via get_azure_ad_token(); this change makes them inputtable from the
UI without code changes to the React components (the form is driven by
GET /public/providers/fields).
2026-04-04 17:16:41 -07:00
Ryan Crabbe
ecb951a320
fix(ui): wire team_id filter to key alias dropdown on Virtual Keys tab
The Key Alias dropdown on the Virtual Keys page was showing aliases from
all teams regardless of which team was selected. The team_id was never
passed through the frontend chain to the backend /key/aliases endpoint.

- Backend: add optional team_id query param to /key/aliases endpoint
- networking.tsx: add team_id param to keyAliasesCall
- useKeyAliases: accept and forward team_id to API call and query key
- filter.tsx: pass allFilters context to custom filter components
- PaginatedKeyAliasSelect: read Team ID from allFilters and pass to hook
2026-04-04 17:16:19 -07:00
Ryan Crabbe
3a3fb83a0a
fix(ui): fix imports and update placeholder for team multi select 2026-04-04 17:15:43 -07:00
Ryan Crabbe
4587097bda
fix(ui): add paginated team search to usage page filter
Replace the static team dropdown on the usage page with a new
TeamMultiSelect component that uses the paginated v2/team/list
endpoint with debounced server-side search and infinite scroll.
2026-04-04 17:15:43 -07:00
Yuneng Jiang
8e3ef6ba11
fix(ui): logs guardrail mode type crash on non-string values
Cherry-pick of PR #24035. Fixes crash when guardrail_mode is null,
array, or object by adding a resolveMode() helper that handles all
shapes.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-04 16:27:43 -07:00
Yuneng Jiang
e738405906
feat(triton): add embedding usage tracking fallback
Cherry-pick of PR #24778. Adds Triton embedding usage estimation from
request input using token counting with a safe word-count fallback.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-04 15:56:57 -07:00
Sameer Kankute
9a5c778f18 Fix greptile reviews and mock test 2026-03-24 11:16:32 +05:30
Sameer Kankute
e05c1b3f01 Fix greptile reviews and mock test 2026-03-24 11:16:32 +05:30
Sameer Kankute
eb32e3a49e Fix greptile reviews and mock test 2026-03-24 11:16:32 +05:30
Sameer Kankute
6f64ed2da3 Fix code qa issues 2026-03-24 11:16:32 +05:30
Sameer Kankute
318e4f1ff0 Fix greptile comments 2026-03-24 11:16:32 +05:30
Sameer Kankute
deb8f0f18d Fix greptile comments 2026-03-24 11:16:32 +05:30
Sameer Kankute
584b821b1a Fix greptile comments 2026-03-24 11:16:32 +05:30
Sameer Kankute
6166d5053f Fix greptile comments 2026-03-24 11:16:32 +05:30
Sameer Kankute
a917c9b786 Fix greptile comments 2026-03-24 11:16:32 +05:30
Sameer Kankute
d1bb9f12f0 fix(routing): address state consistency and type safety issues
- Check alias target pattern to detect stale team aliases
- Fix PrismaClient type annotation to Optional
- Eliminate in-place mutation in index update logic

Made-with: Cursor
2026-03-24 11:16:32 +05:30
Sameer Kankute
2f38bc6c34 perf(routing): optimize team model checks and improve test coverage
- Use O(1) team index lookup instead of map_team_model in alias guard
- Fix MockPrismaClient to validate where clause filters
- Add comment explaining DB query trade-off for team deployments

Made-with: Cursor
2026-03-24 11:16:32 +05:30
Sameer Kankute
c5a6104eef fix(routing): prevent stale model_aliases from interfering with team routing
- Skip model_aliases rewrite if model resolves to team deployments
- Add test coverage for sibling-preservation branch
- Update MockPrismaClient to support sibling deployment scenarios

Made-with: Cursor
2026-03-24 11:16:32 +05:30
Sameer Kankute
3949444e98 fix(router): guard None model_info and deduplicate team index logic
- Guard against None model_info in sibling deployment check
- Extract _update_team_model_index helper to eliminate duplication

Made-with: Cursor
2026-03-24 11:16:32 +05:30
Sameer Kankute
f260173ad7 fix(management): query DB directly for sibling deployments on rename
- Add clarifying comments to test assertions
- Query prisma DB instead of in-memory router to avoid stale state
- Prevents incorrect deletion of old public name when siblings exist

Made-with: Cursor
2026-03-24 11:16:32 +05:30
Sameer Kankute
01b7dfa63b fix(router): prevent cross-team deployment leakage in fallback path
Guard should_include_deployment fallback to only return deployments
matching the requested team_id, preventing public-name collisions
from leaking deployments across teams

Made-with: Cursor
2026-03-24 11:16:32 +05:30
Sameer Kankute
3148d55284 fix(router): address Greptile P1/P2 performance issues
- Guard against llm_router=None to prevent silent deletion
- Add O(1) team_model index to avoid O(n) scan on every team request

Made-with: Cursor
2026-03-24 11:16:32 +05:30
Sameer Kankute
d150174aee fix(router): address remaining Greptile P0/P1 issues
- Update map_team_model test to expect public name return
- Only remove old public name if no sibling deployments use it

Made-with: Cursor
2026-03-24 11:16:32 +05:30
Sameer Kankute
feabe36db1 fix(router): address Greptile review comments
- Add None guard for original_model_name in _add_team_model_to_db
- Remove stale old public name when renaming team model
- Add comment clarifying team deployment early-return priority

Made-with: Cursor
2026-03-24 11:16:32 +05:30
Sameer Kankute
ce1651ef07 chore(team-routing): remove temporary candidate pool logs
Remove temporary fire-emoji router logs used for local verification while keeping team sibling deployment routing behavior unchanged.

Made-with: Cursor
2026-03-24 11:16:32 +05:30
Sameer Kankute
cbd8aa3016 fix(team-routing): keep team model routing on public names
Remove team model_alias rewrites and resolve team deployments by team_public_model_name with team_id so sibling deployments stay in the routing candidate pool, with explicit logs showing candidate selection before load balancing.

Made-with: Cursor
2026-03-24 11:16:32 +05:30
Sameer Kankute
9b1cceb5c4 fix(team-routing): use deterministic team model group names
Use a deterministic internal model_name for team-scoped deployments so sibling deployments with the same public model share a routing group. This makes team alias writes idempotent and preserves multi-deployment failover/load balancing behavior.

Made-with: Cursor
2026-03-24 11:13:38 +05:30
yuneng-jiang
61409275c8 fix(cost_calculator): use model name for per-request custom pricing when router_model_id has no pricing
When custom pricing is passed as per-request kwargs (input_cost_per_token/output_cost_per_token),
completion() registers pricing under the model name, but _select_model_name_for_cost_calc was
selecting the router deployment hash (which has no pricing data), causing response_cost to be 0.0.

Now checks whether the router_model_id entry actually has pricing before preferring it.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-16 12:43:25 -07:00
yuneng-jiang
3283697704 fix(test): update test_startup_fails_when_db_setup_fails for opt-in enforcement
The --enforce_prisma_migration_check flag is now required to trigger
sys.exit(1) on DB migration failure, after #23675 flipped the default
behavior to warn-and-continue.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-16 10:25:30 -07:00
yuneng-jiang
0d4ae8bf9b bump: version 1.82.2 → 1.82.3 2026-03-16 10:08:57 -07:00
yuneng-jiang
8dec9f46e1 fix: handle string callback values in prometheus multiproc setup
When callbacks are configured as a plain string (e.g., `callbacks: "my_callback"`)
instead of a list, the proxy crashes on startup with:
  TypeError: can only concatenate str (not "list") to str

Normalize each callback setting to a list before concatenating.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-16 10:07:36 -07:00
yuneng-jiang
418be368b2 [Fix] Install bsdmainutils for column command in security scans
The security_scans.sh script uses `column` to format vulnerability
output, but the package wasn't installed in the CI environment.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-16 10:07:09 -07:00
yuneng-jiang
c6df5b16a2 Merge commit '58e74a631c9d904de29282206af7d68f392b8e12' into litellm_rc_branch 2026-03-16 10:06:38 -07:00
yuneng-jiang
58e74a631c
Merge pull request #23721 from BerriAI/litellm_ci_optimize
[Infra] Optimize CI Pipeline
2026-03-16 01:04:55 -07:00
yuneng-jiang
8f56ddb9c6 Merge remote main into litellm_ci_optimize
Resolved conflict in test_claude_agent_sdk.py by keeping main's additions.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-16 00:50:22 -07:00
yuneng-jiang
9cec81a087 [Fix] Revert proxy unit test groupings to prevent xdist state pollution
Part1 had 4 test files combined (was originally 2), causing cross-file
state pollution under xdist. Reverted to original grouping.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-16 00:48:56 -07:00
yuneng-jiang
ccfe4b57d5 [Fix] Restore unconditional importlib.reload for llm_translation conftest
The xdist-conditional reload (manual reset in xdist mode) was missing
attributes that importlib.reload resets, causing Azure connection errors.
The original conftest used importlib.reload unconditionally (even under
xdist) and that worked on main. Restore that behavior.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-16 00:35:02 -07:00
yuneng-jiang
2372427dbc [Fix] Remove xdist from caching_unit_tests to fix GCS cache test failures
GCS cache tests (test_gcs_cache_unit_tests.py) rely on module-level state
(vertex_chat_completion singleton, credential caches) that importlib.reload
resets but the xdist-safe function-scoped fixture does not. Removing -n 4
from this job restores single-process execution where module reload properly
resets all state before each test, while CI-level parallelism (parallelism: 2)
still splits test files across nodes.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-16 00:23:04 -07:00
yuneng-jiang
f434cdbdce [Fix] Remove flush_cache from llm_translation conftest to prevent connection churn
The old conftest never flushed HTTP client cache. Adding flush_cache() before
every test forces new TCP connections to external APIs, causing transient
connection failures under xdist parallelism. Global state isolation is already
handled by _SCALAR_DEFAULTS reset.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-16 00:20:40 -07:00
yuneng-jiang
acfaea9d25 [Fix] Reset api_base/api_key in xdist conftest to prevent cross-test leakage
test_rerank.py sets litellm.api_base = "http://localhost:4000" which leaked
to all subsequent tests on the same xdist worker, causing connection failures
across every provider (Cohere, Azure, OpenAI, etc.).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-15 23:55:44 -07:00
yuneng-jiang
5db6aef834 [Fix] Restore xdist test isolation: capture true defaults and poll cooldowns
The revert of 9711e3adfe left xdist tests without proper state isolation.
Module-level assignments like `litellm.num_retries = 3` in 12+ test files
pollute shared globals, and the fixture was saving/restoring contaminated
values instead of resetting to true defaults.

- Capture true litellm defaults at conftest import time and reset before
  each test (local_testing + llm_translation)
- Make llm_translation/conftest.py xdist-safe (skip reload under xdist,
  add state isolation)
- Replace asyncio.sleep(2) with polling in cooldown handler tests

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-15 23:33:21 -07:00
Krish Dholakia
cd37ee1459
fix: make db migration failure exit opt-in via --enforce_prisma_migration_check (#23675)
* fix: improve db migration failure messaging and fix pyright errors in proxy_cli

- Clarify --skip_db_migration_check messaging so users know how to opt
  into warn-and-continue behavior when database setup fails
- Fix pyright reportArgumentType error by casting get_secret result to str
- Fix pyright reportPossiblyUnboundVariable by initializing litellm_settings

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: replace --skip_db_migration_check with --enforce_prisma_migration_check

Flip the default behavior: database migration failures now warn and
continue by default. Only when --enforce_prisma_migration_check (or
ENFORCE_PRISMA_MIGRATION_CHECK=true) is explicitly set will the proxy
exit on migration failure.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-15 23:21:23 -07:00
Krish Dholakia
ca4329aeb9
Root cause fix - migrate all logging update to use 1 function - for centralized kwarg updates (#23659)
* fix: Fixes https://github.com/BerriAI/litellm/issues/23185

* fix(responses/main.py): ensure litellm metadata custom cost works

* refactor: move all logging updates to a common function, to have just 1 place to update logging kwarg updates
2026-03-15 23:21:01 -07:00
yuneng-jiang
96183e8bde [Fix] Drop --no-deps from aurelio_sdk in guardrails and enterprise tests
aurelio_sdk imports requests_toolbelt at load time, so it needs its deps.
Unlike semantic_router, aurelio_sdk has no conflict with openai>=2, so
--no-deps is unnecessary. Verified via uv dry-run locally.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-15 23:11:43 -07:00
yuneng-jiang
f68a9be04d [Infra] Optimize CI: migrate litellm_security_tests from machine to docker xlarge
Switch from expensive Linux machine (medium) to docker xlarge executor.
Drop miniconda, manual Docker CLI install, and manual PostgreSQL container
in favor of cimg/python:3.13, setup_remote_docker, and service container.
Use uv + cache for dependency installation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-15 23:07:22 -07:00