From fe3d47fc9d26a1b003a28795c2280c5b38fcb040 Mon Sep 17 00:00:00 2001 From: shuwenn <47200617+alphabetc1@users.noreply.github.com> Date: Fri, 26 Dec 2025 18:41:15 +0800 Subject: [PATCH] fix: warn once per env var key (#15846) --- python/sglang/srt/utils/common.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/python/sglang/srt/utils/common.py b/python/sglang/srt/utils/common.py index 03174bf1f..6259e9c48 100644 --- a/python/sglang/srt/utils/common.py +++ b/python/sglang/srt/utils/common.py @@ -312,11 +312,13 @@ def get_bool_env_var(name: str, default: str = "false") -> bool: falsy_values = ("false", "0") if (value not in truthy_values) and (value not in falsy_values): - if value not in _warned_bool_env_var_keys: + # Warn once per env var key (not per value), otherwise different keys that share the + # same invalid value may suppress warnings incorrectly. + if name not in _warned_bool_env_var_keys: logger.warning( f"get_bool_env_var({name}) see non-understandable value={value} and treat as false" ) - _warned_bool_env_var_keys.add(value) + _warned_bool_env_var_keys.add(name) return value in truthy_values