reflex-dev/reflex · error · EnvironmentVarValueError
Invalid enum value: {value!r} for {field_name}
Error message
Invalid enum value: {value!r} for {field_name} What it means
interpret_enum_env constructs the enum type from the raw string via field_type(value); if the string isn't a valid member value, the ValueError is re-raised as EnvironmentVarValueError naming the field. Matching is on enum values, not names (unless the enum aliases them).
Source
Thrown at packages/reflex-base/src/reflex_base/environment.py:262
def interpret_enum_env(value: str, field_type: GenericType, field_name: str) -> Any:
"""Interpret an enum environment variable value.
Args:
value: The environment variable value.
field_type: The field type.
field_name: The field name.
Returns:
The interpreted value.
Raises:
EnvironmentVarValueError: If the value is invalid.
"""
try:
return field_type(value)
except ValueError as ve:
msg = f"Invalid enum value: {value!r} for {field_name}"
raise EnvironmentVarValueError(msg) from ve
@dataclasses.dataclass(frozen=True, kw_only=True, slots=True)
class SequenceOptions:
"""Options for interpreting Sequence environment variables."""
delimiter: str = ":"
strip: bool = False
DEFAULT_SEQUENCE_OPTIONS = SequenceOptions()
def interpret_env_var_value(
value: str, field_type: GenericType, field_name: str
) -> Any:
"""Interpret an environment variable value based on the field type.
View on GitHub (pinned to 45b8ed5ab7)
Solutions
- Use an exact enum value string (check the enum definition referenced by the field)
- If you intended the member name, use the value that member maps to
- Pin/verify against the Reflex version's enum members
Example fix
# before LOG_FORMAT=PRETTY # enum values are 'json','text' # after LOG_FORMAT=text
Defensive patterns
Strategy: validation
Validate before calling
allowed = {m.value for m in MyEnum}
assert raw in allowed, f"must be one of {sorted(allowed)}" Type guard
def is_valid_enum_value(v: str, enum_cls: type[enum.Enum]) -> bool:
return v in {m.value for m in enum_cls} Try / catch
except EnvironmentVarValueError:
value = MyEnum.DEFAULT # fallback member Prevention
- Keep an env var cheat-sheet mapping each var to its allowed enum values
- Prefer enum values that match common usage to reduce mismatch
When it happens
Trigger: Setting an enum-typed env var to a string that is not one of the enum's member values, e.g. LOG_FORMAT=pretty when members are 'json' | 'text'.
Common situations: Using an enum member name instead of its value, or values that differ across Reflex versions.
Related errors
- Invalid boolean value: {value!r} for {field_name}
- Invalid integer value: {value!r} for {field_name}
- Invalid float 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/5b7370ac3588b09a.
Report an issue: GitHub.