Skip to content

Commit d7f1cf5

Browse files
authored
ignore env var set to empty string (#5167)
1 parent a420b17 commit d7f1cf5

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

reflex/config.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ def getenv(self) -> T | None:
392392
The environment variable value.
393393
"""
394394
env_value = os.getenv(self.name, None)
395-
if env_value is not None:
395+
if env_value and env_value.strip():
396396
return self.interpret(env_value)
397397
return None
398398

@@ -402,7 +402,7 @@ def is_set(self) -> bool:
402402
Returns:
403403
True if the environment variable is set.
404404
"""
405-
return self.name in os.environ
405+
return bool(os.getenv(self.name, "").strip())
406406

407407
def get(self) -> T:
408408
"""Get the interpreted environment variable value or the default value if not set.
@@ -966,7 +966,7 @@ def update_from_env(self) -> dict[str, Any]:
966966
env_var = os.environ.get(key.upper())
967967

968968
# If the env var is set, override the config value.
969-
if env_var is not None:
969+
if env_var and env_var.strip():
970970
# Interpret the value.
971971
value = interpret_env_var_value(
972972
env_var, true_type_for_pydantic_field(field), field.name

0 commit comments

Comments
 (0)