From b2e123da4332344677fba1b819dc423864cee89c Mon Sep 17 00:00:00 2001 From: mateo Date: Sun, 20 Sep 2026 03:14:11 +0000 Subject: [PATCH] fix(proxy): drop legacy telemetry key from persisted WORKER_CONFIG before initialize Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- .github/template.yaml | 2 +- cookbook/misc/config.yaml | 1 - litellm/proxy/proxy_server.py | 11 +++++++++-- .../test_litellm/proxy/proxy_server/test_lifecycle.py | 11 +++++++++++ 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/.github/template.yaml b/.github/template.yaml index d4db2c2ac1f..c77e578e53c 100644 --- a/.github/template.yaml +++ b/.github/template.yaml @@ -21,7 +21,7 @@ Parameters: WorkerConfigParameter: Type: String Description: Sample environment variable - Default: '{"model": null, "alias": null, "api_base": null, "api_version": "2023-07-01-preview", "debug": false, "temperature": null, "max_tokens": null, "request_timeout": 600, "max_budget": null, "telemetry": true, "drop_params": false, "add_function_to_prompt": false, "headers": null, "save": false, "config": null, "use_queue": false}' + Default: '{"model": null, "alias": null, "api_base": null, "api_version": "2023-07-01-preview", "debug": false, "temperature": null, "max_tokens": null, "request_timeout": 600, "max_budget": null, "drop_params": false, "add_function_to_prompt": false, "headers": null, "save": false, "config": null, "use_queue": false}' Resources: MyUrlFunctionPermissions: diff --git a/cookbook/misc/config.yaml b/cookbook/misc/config.yaml index d1d06eb5842..27a6332a882 100644 --- a/cookbook/misc/config.yaml +++ b/cookbook/misc/config.yaml @@ -55,7 +55,6 @@ litellm_settings: # budget_duration: 30d num_retries: 5 request_timeout: 600 - telemetry: False context_window_fallbacks: [{"gpt-3.5-turbo": ["gpt-3.5-turbo-large"]}] general_settings: diff --git a/litellm/proxy/proxy_server.py b/litellm/proxy/proxy_server.py index df326615764..9c4ea7e8599 100644 --- a/litellm/proxy/proxy_server.py +++ b/litellm/proxy/proxy_server.py @@ -1208,12 +1208,12 @@ async def proxy_startup_event(app: FastAPI) -> AsyncGenerator[None, None]: general_settings, ) = await proxy_config.load_config(router=llm_router, config_file_path=worker_config) elif isinstance(worker_config, dict): - await initialize(**worker_config) + await initialize_from_worker_config(worker_config) else: # if not, assume it's a json string worker_config = json.loads(worker_config) if isinstance(worker_config, dict): - await initialize(**worker_config) + await initialize_from_worker_config(worker_config) # check if DATABASE_URL in environment - load from there if prisma_client is None: @@ -8568,6 +8568,13 @@ def save_worker_config(**data): os.environ["WORKER_CONFIG"] = json.dumps(data) +LEGACY_WORKER_CONFIG_KEYS: Final = frozenset({"telemetry"}) + + +async def initialize_from_worker_config(worker_config: dict[str, object]) -> None: + await initialize(**{k: v for k, v in worker_config.items() if k not in LEGACY_WORKER_CONFIG_KEYS}) + + async def initialize( model=None, alias=None, diff --git a/tests/test_litellm/proxy/proxy_server/test_lifecycle.py b/tests/test_litellm/proxy/proxy_server/test_lifecycle.py index ba560cebd52..e9695685ca5 100644 --- a/tests/test_litellm/proxy/proxy_server/test_lifecycle.py +++ b/tests/test_litellm/proxy/proxy_server/test_lifecycle.py @@ -43,6 +43,7 @@ from litellm.proxy.proxy_server import ( cost_tracking, get_litellm_model_info, initialize, + initialize_from_worker_config, load_from_azure_key_vault, proxy_shutdown_event, proxy_startup_event, @@ -522,6 +523,16 @@ async def test_initialize_invalid_unexpected_kwarg_raises_type_error(): await initialize(this_is_not_a_real_kwarg=True) +@pytest.mark.asyncio +async def test_initialize_from_worker_config_drops_legacy_telemetry_key(): + with pytest.raises(TypeError): + await initialize(telemetry=True) + await initialize_from_worker_config({"telemetry": True, "request_timeout": 77}) + assert ps.user_request_timeout == 77 + with pytest.raises(TypeError): + await initialize_from_worker_config({"this_is_not_a_real_kwarg": True}) + + # --------------------------------------------------------------------------- # load_from_azure_key_vault # ---------------------------------------------------------------------------