Commit graph

31053 commits

Author SHA1 Message Date
Alexsander Hamir
f50e7e71b2 ci: validate Docker nightly image exists when PyPI package found
Prevents silent incomplete releases by checking if Docker nightly image exists when PyPI package is already published. If both exist, the release was completed successfully and the workflow halts gracefully. If only PyPI exists, fail with an error to indicate the release needs investigation.
2026-01-27 17:04:07 -08:00
Alexsander Hamir
f49f87a3dd test: improve robustness of Gemini function calling test
Increased retry attempts from 3 to 6 with longer delay (2s) for the Vertex AI Gemini function calling test. Added explicit timeout parameter and improved exception handling to skip (rather than fail) on transient API issues like rate limits, service unavailability, and timeouts. This prevents legitimate external API issues from blocking releases.
2026-01-27 16:19:22 -08:00
Alexsander Hamir
6ff86dd53e fix: prevent logging errors during worker shutdown
Added pre-flight checks in _safe_log to verify logger handlers are valid and their streams are open before attempting to log. This prevents 'I/O operation on closed file' errors during pytest-xdist worker shutdown when atexit handlers run after Python has closed file handles.
2026-01-27 16:00:49 -08:00
Alexsander Hamir
95e635b842 ci: fix workspace collision for router coverage files
Renamed coverage files from litellm_router_unit_testing job to avoid conflict with litellm_router_testing job. Both jobs were persisting files with identical names causing workspace layer collision during parallel execution.
2026-01-27 15:54:52 -08:00
Alexsander Hamir
88347bba9a ci: use current branch for Docker builds on release branches
Enhanced the Docker deployment workflow to automatically detect and use the current branch for building containers when running on release day branches, improving deployment consistency.
2026-01-27 15:00:47 -08:00
Alexsander Hamir
4aef0c209c ci: streamline test dependencies for deployment jobs
Adjusted test job requirements in CI workflow to optimize build pipeline performance and reduce dependency complexity for coverage and publishing tasks.
2026-01-27 14:05:35 -08:00
Alexsander Hamir
33470fe269 fix(test): use autouse fixture to ensure module cleanup across all tests
Added autouse fixture that reloads constants and auth_checks modules before and after each test. This ensures complete test isolation and prevents any test from polluting module state for subsequent tests, regardless of test execution order.
2026-01-27 13:06:08 -08:00
Alexsander Hamir
173652ab19 docs: add CLI_JWT_EXPIRATION_HOURS to environment variables reference
Added documentation for CLI_JWT_EXPIRATION_HOURS which is an alternative to LITELLM_CLI_JWT_EXPIRATION_HOURS for configuring JWT token expiration.
2026-01-27 12:50:47 -08:00
Alexsander Hamir
8ac3aa3565 fix(constants): support both CLI_JWT_EXPIRATION_HOURS env var patterns
The constant CLI_JWT_EXPIRATION_HOURS now checks both:
1. CLI_JWT_EXPIRATION_HOURS (without LITELLM_ prefix)
2. LITELLM_CLI_JWT_EXPIRATION_HOURS (with prefix, for backwards compatibility)

This ensures the test_all_numeric_constants_can_be_overridden test passes while maintaining backwards compatibility for users who set LITELLM_CLI_JWT_EXPIRATION_HOURS.
2026-01-27 12:42:24 -08:00
Alexsander Hamir
4a0d63d063 fix(test): add cleanup to prevent test pollution in CLI JWT expiration tests
The custom expiration test was setting LITELLM_CLI_JWT_EXPIRATION_HOURS=48 and reloading modules, but not cleaning up afterwards. This caused subsequent tests to use the cached 48-hour value instead of the default 24 hours.

Added request.addfinalizer() to properly reload modules after the test completes, ensuring test isolation.
2026-01-27 12:39:05 -08:00
Alexsander Hamir
150363be0b fix(test): mock Lakera API in PII masking test for deterministic behavior
Changed from integration test to unit test by mocking the Lakera API response. This makes the test:
- Deterministic and not dependent on external API behavior
- Consistent with other tests in the file which are all mocked
- Able to test the masking logic regardless of Lakera's detection of test data
- Faster and more reliable in CI/CD

The mock response includes both credit card and email in the payload with proper start/end positions so we can verify the masking logic works correctly.
2026-01-27 12:30:47 -08:00
Alexsander Hamir
631b503267 fix(test): update Lakera PII masking test to handle API behavior
Lakera's API may not consistently return test credit card numbers (like 4111-1111-1111-1111) in the payload field for masking. Updated test to focus on email masking which works reliably, and made assertions more flexible.
2026-01-27 12:28:49 -08:00
Alexsander Hamir
e5b0ac30aa fix(test): reload auth_checks module in CLI JWT expiration test
The test was reloading the constants module but not auth_checks, which imports CLI_JWT_EXPIRATION_HOURS at module level. This caused the test to use the old cached value instead of the new environment variable value.
2026-01-27 12:19:24 -08:00
Alexsander Hamir
95796eb846 fix(security): upgrade python-multipart from 0.0.18 to 0.0.22
Addresses GHSA-wp53-j4wj-2cfg (CVE with CVSS 8.6) - Arbitrary File Write vulnerability. Updated python-multipart to version 0.0.22 which includes the security fix.
2026-01-27 12:16:21 -08:00
Alexsander Hamir
d6544f0ca7 docs: add LITELLM_CLI_JWT_EXPIRATION_HOURS to environment variables reference
Add missing documentation for LITELLM_CLI_JWT_EXPIRATION_HOURS environment variable to fix documentation test failure.
2026-01-27 12:12:52 -08:00
Harshit Jain
306956ee83 feat: tpm-rpm limit in prometheus metrics (#19725)
Co-authored-by: Krish Dholakia <krrishdholakia@gmail.com>
2026-01-27 12:09:31 -08:00
Alexsander Hamir
2ad675c6fe Allow publish_proxy_extras to run on release branch 2026-01-27 12:01:41 -08:00
Alexsander Hamir
f95572e3ed
Fix broken mocks in 6 flaky tests to prevent real API calls (#19829)
* Fix broken mocks in 6 flaky tests to prevent real API calls

Added network-level HTTP blocking using respx to prevent tests from making real API calls when Python-level mocks fail. This makes tests more reliable and retryable in CI.

Changes:

- Azure OIDC test: Added Azure Identity SDK mock to prevent real Azure calls

- Vector store test: Added @respx.mock decorator to block HTTP requests

- Resend email tests (3): Added @respx.mock decorator for all 3 test functions

- SendGrid email test: Added @respx.mock decorator

All test assertions and verification logic remain unchanged - only added safety nets to catch leaked API calls.

* Fix failing OIDC secret manager tests

Fixed two test failures in test_secret_managers_main.py:

1. test_oidc_azure_ad_token_success: Corrected the patch path for get_bearer_token_provider from 'litellm.secret_managers.get_azure_ad_token_provider.get_bearer_token_provider' to 'azure.identity.get_bearer_token_provider' since the function is imported from azure.identity.

2. test_oidc_google_success: Added @patch('httpx.Client') decorator to prevent any real HTTP connections during test execution, resolving httpx.ConnectError issues.

Both tests now pass successfully.
2026-01-26 17:39:40 -08:00
Alexsander Hamir
c442fcd922
CI/CD: Increase retries and stabilize litellm_mapped_tests_core (#19826)
* Fix PLR0915: Extract system message handling to reduce statement count

* fix mypy

* fix: add host_progress_callback parameter to mock_call_tool in test

The test_call_tool_without_broken_pipe_error was failing because the mock function did not accept the host_progress_callback keyword argument that the actual implementation passes to client.call_tool(). Updated the mock to accept this parameter to match the real implementation signature.

* fixing flaky tests around oidc and email

* Add documentation comment to test file

* add retry

* add dependency

* increase retry

---------

Co-authored-by: yuneng-jiang <yuneng.jiang@gmail.com>
2026-01-26 17:00:18 -08:00
mubashir1osmani
8908eff7b1
Fix(#19781): Unable to reset user max budget to unlimited
Fix(#19781): Unable to reset user max budget to unlimited
2026-01-26 18:37:49 -05:00
yuneng-jiang
801e0a6ce6
Merge pull request #19819 from BerriAI/litellm_cd_fix_yj_10
[Infra] CI/CD - Fixing Flaky Tests in OIDC and Email
2026-01-26 15:29:55 -08:00
mubashir1osmani
5d973477e6
fix(ui): prevent clearing content filter patterns when editing guardrail
fix(ui): prevent clearing content filter patterns when editing guardrail
2026-01-26 18:29:48 -05:00
yuneng-jiang
33b4b444ac fixing flaky tests around oidc and email 2026-01-26 15:23:17 -08:00
Ishaan Jaff
cec1a3c858
[Feat] CLI Auth - Add configurable CLI JWT expiration via environment variable (#19780)
* fix: add CLI_JWT_EXPIRATION_HOURS

* docs: CLI_JWT_EXPIRATION_HOURS

* fix: get_cli_jwt_auth_token

* test_get_cli_jwt_auth_token_custom_expiration
2026-01-26 14:56:17 -08:00
houdataali
29ee5aab5c
[Feat] enable progress notifications for MCP tool calls (#19809)
* enable progress notifications for MCP tool calls

* adjust mcp test
2026-01-26 14:48:22 -08:00
colinlin-stripe
7605062e94
Messages api bedrock converse caching and pdf support (#19785)
* cache control for user messages and system messages

* add cache createion tokens in reponse

* cache controls in tool calls and assistant turns

* refactor with _should_preserve_cache_control

* add cache control unit tests

* use simpler cache creation token count logic

* use helper function

* remove unused function

* fix unit tests
2026-01-26 13:19:56 -08:00
Alexsander Hamir
f2c3a01a57
fix: make HTTPHandler mockable in OIDC secret manager tests (#19803)
* fix: make HTTPHandler mockable in OIDC secret manager tests

- Add _get_oidc_http_handler() factory function to make HTTPHandler
  easily mockable in tests
- Update test_oidc_github_success to patch factory function instead
  of HTTPHandler directly
- Update Google OIDC tests for consistency
- Fixes test_oidc_github_success failure where mock was bypassed

This change allows tests to properly mock HTTPHandler instances used
for OIDC token requests, fixing the test failure where the mock was
not being used.

* fix: patch base_llm_http_handler method directly in container tests

- Use patch.object to patch container_create_handler method directly
  on the base_llm_http_handler instance instead of patching the module
- Fixes test_provider_support[openai] failure where mock wasn't applied
- Also fixes test_error_handling_integration with same approach

The issue was that patching 'litellm.containers.main.base_llm_http_handler'
didn't work because the module imports it with 'from litellm.main import',
creating a local reference. Using patch.object patches the method on the
actual object instance, which works regardless of import style.

* fix: resolve flaky test_openai_env_base by clearing cache

- Add cache clearing at start of test_openai_env_base to prevent cache pollution
- Ensures no cached clients from previous tests interfere with respx mocks
- Fixes intermittent failures where aiohttp transport was used instead of httpx
- Test-only change with low risk, no production code modifications

Resolves flaky test marked with @pytest.mark.flaky(retries=3, delay=1)
Both parametrized versions (OPENAI_API_BASE and OPENAI_BASE_URL) now pass consistently

* test: add explicit mock verification in test_provider_support

- Capture mock handler with 'as mock_handler' for explicit validation
- Add assert_called_once() to verify mock was actually used
- Ensures test verifies no real API calls are made
- Follows same pattern as test_openai_env_base validation
2026-01-26 11:00:42 -08:00
Alexsander Hamir
a8e72950db
Fix test_mcp_server_manager_config_integration_with_database cancellation error (#19801)
Mock _create_mcp_client to avoid network calls in health checks.
This prevents asyncio.CancelledError when the test teardown closes
the event loop while health checks are still pending.

The test focuses on conversion logic (access_groups, description)
not health check functionality, so mocking the network call is appropriate.
2026-01-26 10:52:49 -08:00
Alexsander Hamir
4a6dcf3012
Add test for Router.get_valid_args, fix router code coverage encoding (#19797)
- Add test_get_valid_args in test_router_helper_utils.py to cover get_valid_args
- Use encoding='utf-8' in router_code_coverage.py for cross-platform file reads
2026-01-26 10:14:58 -08:00
Alexsander Hamir
c0d6998384
Make test_get_users_key_count deterministic by creating dedicated test user (#19795)
- Create a test user with auto_create_key=False to ensure known starting state
- Filter get_users by user_ids to target only the test user
- Verify initial key count is 0 before creating a key
- Clean up test user after test completes
- This ensures consistent behavior across CI and local environments
2026-01-26 10:13:15 -08:00
yogeshwaran10
228aff9b9f Fix user max budget reset to unlimited
- Added a Pydantic validator to convert empty string inputs for max_budget to None, preventing float parsing errors from the frontend.
- Modified the internal user update logic to explicitly allow max_budget to be None, ensuring the value isn't filtered out and can be reset to unlimited in the database.
- Added unit tests for validation and logic.

 Closes #19781
2026-01-26 23:30:36 +05:30
Alexsander Hamir
de3bbc216d
refactor: extract transport context creation into separate method (#19794) 2026-01-26 09:57:53 -08:00
Harshit Jain
b920be3ee7
fix: server rooth path (#19790) 2026-01-26 09:48:06 -08:00
Alexsander Hamir
8ece284ca3
bump: version 1.81.3 → 1.81.4 (#19793) 2026-01-26 09:41:25 -08:00
michelligabriele
558f01e848
fix(proxy): use return value from CustomLogger.async_post_call_success_hook (#19670)
* fix(proxy): use return value from CustomLogger.async_post_call_success_hook

Previously the return value was ignored for CustomLogger callbacks,
preventing users from modifying responses. Now the return value is
captured and used to replace the response (if not None), consistent
with CustomGuardrail and streaming iterator hook behavior.

Fixes issue with custom_callbacks not being able to inject data into
LLM responses.

* fix(proxy): also fix async_post_call_streaming_hook to use return value

Previously the streaming hook only used return values that started with
"data: " (SSE format). Now any non-None return value is used, consistent
with async_post_call_success_hook and streaming iterator hook behavior.

Added tests for streaming hook transformation.

---------

Co-authored-by: Gabriele Michelli <michelligabriele0@gmail.com>
2026-01-26 08:48:22 -08:00
Harshit Jain
667b9122e0
Merge pull request #19720 from Harshit28j/fix/model_alias_map-argument-error
fix: args issue & refactor into helper function to reduce bloat for b…
2026-01-25 10:51:28 +05:30
Harshit Jain
6df0406cf6
fix: args issue & refactor into helper function to reduce bloat for both(#19441) 2026-01-25 10:21:20 +05:30
yuneng-jiang
edfb1b8fe1
Merge pull request #19718 from BerriAI/litellm_ui_team_member_add_error
[Feature] UI - Virtual Keys: Auto Truncation of Table Values
2026-01-24 18:58:54 -08:00
yuneng-jiang
6ffd8a1d32 auto truncation of virtual keys table values 2026-01-24 18:03:32 -08:00
Ishaan Jaffer
e41b9c29a8 fix MCP tests 2026-01-24 18:00:22 -08:00
Ishaan Jaffer
f148207b11 fix patch reliability mock tests 2026-01-24 17:37:17 -08:00
Ishaan Jaffer
73dd1bd97a test_stream_transformation_error_sync 2026-01-24 17:19:21 -08:00
yuneng-jiang
06f7a7ec69
Merge pull request #19716 from BerriAI/ui_build_yj_0124_2
[Infra] Rebuilding UI
2026-01-24 16:28:22 -08:00
yuneng-jiang
3c94458f35 chore: update Next.js build artifacts (2026-01-25 00:27 UTC, node v22.16.0) 2026-01-24 16:27:30 -08:00
yuneng-jiang
8094aff8c5
Merge pull request #19715 from BerriAI/key_teams_fallback_docs
[Docs] UI Keys Teams Router Settings docs
2026-01-24 16:26:28 -08:00
yuneng-jiang
937ccf1977 UI Keys Teams Router Settings docs 2026-01-24 16:23:46 -08:00
Harshit Jain
05fdd099ba
fix(presidio): resolve runtime error by handling asyncio loops in bac… (#19714)
* fix(presidio): resolve runtime error by handling asyncio loops in background threads

* add test case for thread safety
2026-01-24 15:36:49 -08:00
Ishaan Jaffer
53d3868ff2 TestBedrockInvokeToolSearch 2026-01-24 15:36:30 -08:00
yuneng-jiang
99e9462ec9
Merge pull request #19713 from BerriAI/litellm_model_search_id_team
[Feature] UI - Model Page: Filter by Model ID and Team ID
2026-01-24 15:04:20 -08:00
yuneng-jiang
47810f1523 Model and Team filtering 2026-01-24 14:45:14 -08:00