Commit Graph

26 Commits

Author SHA1 Message Date
Ishaan Jaff bab4127cae fix(tests): fix flaky test_use_prisma_db_push_flag_behavior (#21849)
Replace Click CliRunner with standalone_mode=False to avoid
"I/O operation on closed file" errors caused by Click's stream
isolation in CI environments.
2026-02-21 15:23:55 -08:00
Ishaan Jaff fb4249005e fix(tests): add atexit.register mock to prevent Click isolation stream closure in test_use_prisma_db_push_flag_behavior (#21829) 2026-02-21 14:28:02 -08:00
Ishaan Jaff dd6a74da63 fix(tests): isolate litellm.cache and CLI env vars in flaky tests (#21821)
- TestSpendLogsPayload: save/restore litellm.cache in setup_method/teardown_method
  so tests that run after a cache-setting test don't see a non-None cache and get
  a hash instead of "Cache OFF" in the cache_key field
- test_use_prisma_db_push_flag_behavior: apply clean_env pattern (strip DATABASE_URL/DIRECT_URL,
  then set DATABASE_URL to test value) inside the with block instead of using @patch.dict
  decorator, matching the pattern from test_skip_server_startup to avoid Click 8.3.x
  StreamMixer stream lifecycle issues in CI
2026-02-21 14:11:48 -08:00
Ishaan Jaff 87feca0b4a fix: 2 failing CI tests in litellm_mapped_tests_proxy_part2 (#21797)
* fix(test): remove deprecated Click mix_stderr param in test_use_prisma_db_push_flag_behavior

Click 8.2+ removed the mix_stderr parameter from CliRunner. Use CliRunner() without it.

* fix(test): use app.dependency_overrides for auth mock in test_role_mappings_stored_and_retrieved

monkeypatch.setattr doesn't affect FastAPI's Depends() resolution in parallel
test execution. Use app.dependency_overrides which is the proper FastAPI pattern.
2026-02-21 12:04:58 -08:00
Ishaan Jaff 3e67cb5287 fix: resolve flaky test failures in health, spend logs, and CLI tests (#21769)
* fix: reset db_health_cache in source module to prevent stale cache hits

The test was reassigning db_health_cache via `global` in the test module,
which doesn't affect the _health_endpoints module's variable. When a prior
test set the cache to "connected" within 2 minutes, _db_health_readiness_check
returned early without calling health_check(), causing assert_called_once to fail.

Also use PrismaError with a connection message so it's properly recognized
as a connection error by PrismaDBExceptionHandler.is_database_connection_error.

* fix: replace asyncio.sleep with polling loop in spend logs tests

The GLOBAL_LOGGING_WORKER processes callbacks via an async queue, so
asyncio.sleep(1) is a race condition - under CI load the worker may not
have processed the queued task within 1 second. Replace with a polling
helper that waits up to 10 seconds for the mock to be called.

Also add metadata.attempted_retries and metadata.max_retries to
ignored_keys since these are new fields.

* fix: isolate test_skip_server_startup from CI environment

Remove mix_stderr=False (unsupported in some Click versions). Strip
DATABASE_URL/DIRECT_URL from environment during the test to prevent
real prisma operations when these are set in CI.
2026-02-21 10:02:24 -08:00
yuneng-jiang e6b9bef949 [Fix] Fix flaky tests: spend logs metadata keys, proxy CLI isolation, Redis TTL uniqueness
- Add new SpendLogsMetadata keys to ignored_keys in spend logs tests
  (regression from ccecc10c82 which intentionally includes all keys)
- Mock PrismaManager.setup_database and should_update_prisma_schema in
  proxy CLI tests to prevent real DB migrations from running in CI
- Use CliRunner(mix_stderr=False) to fix Click stream lifecycle issues
- Use unique UUID suffix for Redis TTL test keys to avoid stale state

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-02-20 17:26:44 -08:00
Ishaan Jaff 323aed7211 fix: CI failures - missing env key doc + streaming test (#21510)
* docs: add DATABRICKS_API_KEY to environment settings reference

* fix: streaming test usage check on Pydantic model

* fix: mock litellm.proxy.proxy_server in test_skip_server_startup
2026-02-18 18:20:32 -08:00
yuneng-jiang efe84777e5 fixing no_config test 2026-02-16 20:13:45 -08:00
Vincent Koc 0dcc744f7e fix(proxy): handle missing DATABASE_URL in append_query_params (#21239)
* fix: handle missing database url in append_query_params

* Update litellm/proxy/proxy_cli.py

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>

---------

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
2026-02-16 09:03:10 -08:00
Ishaan Jaffer 31a4cb65bf test_get_default_unvicorn_init_args 2026-01-24 12:59:51 -08:00
yuneng-jiang 8b5b343841 attempt fix flaky tests 2026-01-23 12:10:08 -08:00
YutaSaito 7aba0f738a Revert "Litellm staging 01 15 2026" 2026-01-17 06:31:34 +09:00
Kris Xia ccc0e342f2 Make keepalive_timeout parameter work for Gunicorn (#19087)
* [Fix] Containers API - Allow routing to regional endpoints (#19118)

* fix get_complete_url

* fix url resolution containers API

* TestContainerRegionalApiBase

* feat(proxy): add keepalive_timeout support for Gunicorn server

Add configurable keepalive timeout parameter for Gunicorn workers to
match existing Uvicorn functionality. This allows users to tune the
keep-alive connection timeout based on their deployment requirements.

Changes:
- Add keepalive_timeout parameter to _run_gunicorn_server method
- Configure Gunicorn's keepalive setting (defaults to 90s if not specified)
- Update --keepalive_timeout CLI help text to document both Uvicorn and Gunicorn behavior
- Pass keepalive_timeout from run_server to _run_gunicorn_server

Tests:
- Add test to verify keepalive_timeout flag is properly passed to Gunicorn
- Add test to verify default 90s timeout when flag is not specified

Co-Authored-By: lizhen921 <294474470@qq.com>
Signed-off-by: Kris Xia <xiajiayi0506@gmail.com>

---------

Signed-off-by: Kris Xia <xiajiayi0506@gmail.com>
Co-authored-by: Ishaan Jaff <ishaanjaffer0324@gmail.com>
Co-authored-by: lizhen921 <294474470@qq.com>
2026-01-16 03:32:59 +05:30
Alexsander Hamir 5534038e93 Fix CI: Revert security scan changes and add GitGuardian ignore rules (#18358) 2025-12-22 17:03:53 -08:00
Ishaan Jaffer 6112160a16 Revert "[Fix] Security - Remove example API keys with high entropy (#18255)"
This reverts commit 24edbccf5c.
2025-12-20 20:48:11 +05:30
Alexsander Hamir 24edbccf5c [Fix] Security - Remove example API keys with high entropy (#18255) 2025-12-19 10:09:50 -08:00
TobiMayr 3c99d2236a feature/add max requests env var 2025-09-28 19:18:56 +01:00
Krish Dholakia f00e891004 LiteLLM SDK <-> Proxy: support user param + Prisma - remove use_prisma_migrate flag - redundant as this is now default (#13555)
* fix(litellm_proxy/chat/transformation.py): support 'user' and all other openai chat completion params

Fixes issue where 'user' was not being sent in request to litellm proxy via sdk

* fix(prisma_migration.py): remove 'use_prisma_migrate' flag, is now default

* docs: cleanup docs

* fix(proxy_cli.py): remove --use_prisma_migrate flag

* refactor: remove references to use_prisma_migrate env var

This is now the default flow for db migrations
2025-08-12 22:03:39 -07:00
Jugal D. Bhatt 524a1ffd5f [Proxy Startup]fix db config through envs (#13111)
* fix db config through envs

* add helper

* fix ruff

* fix imports

* add unit tests in db config changes
2025-07-31 13:52:56 -07:00
Jugal D. Bhatt a112ec5b02 Health check app on separate port (#12718)
* add separate health app

* add new docs

* refactor

* fix colons

* Update config_settings.md

* refactor

* docs

* add unit test

* added supervisord

* remove app

* add supervisor conf

* Add markdown

* add video to md

* remove test

* docs build failure

* add to all docker files, change prod.md and add tests

* change dockerfiles

* remove extra file

* remove extra file

* remove extra file

* change apt->apk

* remove rdb file

* add fixed file
2025-07-18 11:17:15 -07:00
Jugal D. Bhatt 4b09d0d517 [Liveness/Liveliness probe] add separate health app for liveness probes in files (#12669)
* add separate health app

* add new docs

* refactor

* fix colons

* Update config_settings.md

* refactor

* docs

* add unit test
2025-07-16 20:35:09 -07:00
frank 0d486120bc add ciphers in command and pass to hypercorn for proxy (#11916)
Signed-off-by: frankzye1 <frankzye@qq.com>
2025-06-20 14:45:48 -07:00
Ishaan Jaff 55cd5f096c [Feat] LiteLLM Allow setting Uvicorn Keep Alive Timeout (#11594)
* Add keepalive timeout option for uvicorn server configuration

* docs Keepalive Timeout

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
2025-06-10 13:30:19 -07:00
Ishaan Jaff 08d6f3e142 Revert "Enhance proxy CLI with Rich formatting and improved user experience (#11420)"
This reverts commit 3b911ba1b2.
2025-06-06 17:55:45 -07:00
Cole McIntosh 3b911ba1b2 Enhance proxy CLI with Rich formatting and improved user experience (#11420)
* Enhance proxy CLI with Rich formatting and improved user experience

- Integrated Rich library for better console output in `proxy_cli.py`, including version display, health check results, and test completion responses.
- Updated health check and test completion methods to provide progress indicators and formatted tables.
- Refactored feedback display in `proxy_server.py` to use Rich for a more visually appealing user interface.
- Adjusted tests in `test_proxy_cli.py` to mock console output instead of using print statements, ensuring compatibility with Rich formatting.

* fix linting error

* refactor(proxy_cli.py): simplify DB setup logging

- Removed progress indicators for IAM token generation and environment variable decryption to simplify the code.
- Consolidated the logic for generating the database URL and setting environment variables.
- Enhanced error handling for configuration loading and database setup, ensuring clearer feedback

* Update test-linting workflow to include proxy-dev dependencies in Poetry installation

* Enhance proxy server initialization with Rich console for improved model display. Added support for loading model parameters from environment variables and refined provider identification logic. Fallback to original print formatting if Rich is not available.

* Refactor feedback handling: Moved feedback message generation and custom warning display to utils.py. Enhanced feedback box with rich formatting and fallback to ASCII for environments without rich. Cleaned up proxy_server.py by removing obsolete code.

* fix linting error

* Refactor model initialization display: Moved model initialization logic to a new utility function `display_model_initialization` for improved readability and maintainability. Enhanced model provider extraction with a dedicated function. Fallback to basic logging if Rich console is unavailable.

* Refactor model provider extraction: Replace the `_extract_provider_from_model` function with a more robust approach using `get_llm_provider`. Implement fallback logic for provider identification and improve error handling. Ensure compatibility with Rich console for model initialization display.
2025-06-06 17:16:53 -07:00
Krish Dholakia ef42461c1e Litellm fix GitHub action testing (#11163)
* test: add __init__.py files

* refactor: rename test folder to avoid naming conflict

* test: update workflows

* test: update tests

* test: update imports

* test: update tests

* test: remove unused import

* ci(test-litellm.yml): add pytest retry to github workflow

* test: fix test
2025-05-26 14:41:42 -07:00