From 81cd924090ba8fd7bc0cc723e8e3d7003d95e2b7 Mon Sep 17 00:00:00 2001 From: Daniel Peng Date: Sun, 13 Sep 2026 14:05:22 +0800 Subject: [PATCH] fix(proxy): namespace debug environment variables --- litellm/proxy/proxy_cli.py | 4 ++-- tests/test_litellm/proxy/test_proxy_cli.py | 23 ++++++++++++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/litellm/proxy/proxy_cli.py b/litellm/proxy/proxy_cli.py index 01a3da08998..3794661e6b4 100644 --- a/litellm/proxy/proxy_cli.py +++ b/litellm/proxy/proxy_cli.py @@ -706,7 +706,7 @@ class ProxyInitializationHelpers: is_flag=True, type=bool, help="To debug the input", - envvar="DEBUG", + envvar="LITELLM_DEBUG", ) @click.option( "--detailed_debug", @@ -714,7 +714,7 @@ class ProxyInitializationHelpers: is_flag=True, type=bool, help="To view detailed debug logs", - envvar="DETAILED_DEBUG", + envvar="LITELLM_DETAILED_DEBUG", ) @click.option( "--use_queue", diff --git a/tests/test_litellm/proxy/test_proxy_cli.py b/tests/test_litellm/proxy/test_proxy_cli.py index e25e6a59884..4987895a242 100644 --- a/tests/test_litellm/proxy/test_proxy_cli.py +++ b/tests/test_litellm/proxy/test_proxy_cli.py @@ -1,5 +1,6 @@ import inspect import os +from collections.abc import Mapping from pathlib import Path from types import SimpleNamespace from unittest.mock import AsyncMock, MagicMock, patch @@ -21,6 +22,28 @@ from uvicorn.importer import import_from_string from litellm.proxy.proxy_cli import ProxyInitializationHelpers, run_server +@pytest.mark.parametrize( + ("environment", "arguments", "expected_debug", "expected_detailed_debug"), + ( + ({"DEBUG": "release"}, (), False, False), + ({"LITELLM_DEBUG": "1"}, (), True, False), + ({"DETAILED_DEBUG": "release"}, (), False, False), + ({"LITELLM_DETAILED_DEBUG": "1"}, (), False, True), + ({}, ("--debug", "--detailed_debug"), True, True), + ), +) +def test_debug_options_use_namespaced_environment_variables( + environment: Mapping[str, str], + arguments: tuple[str, ...], + expected_debug: bool, + expected_detailed_debug: bool, +) -> None: + with patch.dict(os.environ, environment, clear=True): + with run_server.make_context("litellm", list(arguments)) as context: + assert context.params["debug"] is expected_debug + assert context.params["detailed_debug"] is expected_detailed_debug + + @pytest.mark.xdist_group("proxy_cli") class TestProxyInitializationHelpers: @patch("importlib.metadata.version")