reflex-dev/reflex · error · EnvironmentVarValueError
Invalid boolean value: {value!r} for {field_name}
Error message
Invalid boolean value: {value!r} for {field_name} What it means
interpret_boolean_env only accepts a fixed set of truthy/falsy strings (case-insensitive); any other value raises EnvironmentVarValueError. This guards config fields typed bool from silently coercing arbitrary strings like Python's bool('false') == True would.
Source
Thrown at packages/reflex-base/src/reflex_base/environment.py:76
Args:
value: The environment variable value.
field_name: The field name.
Returns:
The interpreted value.
Raises:
EnvironmentVarValueError: If the value is invalid.
"""
true_values = ["true", "1", "yes", "y"]
false_values = ["false", "0", "no", "n"]
if value.lower() in true_values:
return True
if value.lower() in false_values:
return False
msg = f"Invalid boolean value: {value!r} for {field_name}"
raise EnvironmentVarValueError(msg)
def interpret_int_env(value: str, field_name: str) -> int:
"""Interpret an integer environment variable value.
Args:
value: The environment variable value.
field_name: The field name.
Returns:
The interpreted value.
Raises:
EnvironmentVarValueError: If the value is invalid.
"""
try:
return int(value)
except ValueError as ve:View on GitHub (pinned to 45b8ed5ab7)
Solutions
- Use one of the accepted boolean words (typically 'true'/'false', case-insensitive)
- Strip quotes/whitespace from the env value (common with CI/CD secret interpolation)
- Check the accepted true/false lists in reflex_base.environment and align your value
Example fix
# before TELEMETRY_ENABLED=fals # typo # after TELEMETRY_ENABLED=false
Defensive patterns
Strategy: validation
Validate before calling
import re
TRUE = {"true", "1", "yes", "on"}
FALSE = {"false", "0", "no", "off"}
v = os.environ.get("FLAG", "").strip().lower()
assert v in TRUE | FALSE, f"FLAG must be one of {sorted(TRUE | FALSE)}" Type guard
def is_valid_bool_env(v: str) -> bool:
return v.strip().lower() in {"true", "false", "1", "0", "yes", "no", "on", "off"} Try / catch
from reflex_base.environment import EnvironmentVarValueError
try:
interpret_boolean_env(raw, "FLAG")
except EnvironmentVarValueError as e:
raw = "false" # safe default Prevention
- Standardize on lowercase true/false everywhere
- Strip whitespace/quotes when injecting secrets via CI
When it happens
Trigger: Setting a bool-typed env var (e.g. TELEMETRY_ENABLED=false is fine, but TELEMETRY_ENABLED=0/1/off variants outside the accepted lists, or a stray value like 'fals') and starting the app; interpret_env_var_value dispatches to this function for bool fields.
Common situations: Using 2/1 style flags, values with whitespace or quotes from CI secrets, or 'yes'/'no' when not in the accepted sets.
Related errors
- Invalid integer value: {value!r} for {field_name}
- Invalid float value: {value!r} for {field_name}
- Invalid enum value: {value!r} for {field_name}
- Could not interpret {value!r} for {field_name} as any of {un
- Invalid log level value: {value} for {field_name}
AI-assisted analysis of reflex-dev/reflex@45b8ed5ab7 (2026-08-28).
Data as JSON: /api/errors/896cbc60627eb8db.
Report an issue: GitHub.