reflex-dev/reflex · error · EnvironmentVarValueError
Invalid integer value: {value!r} for {field_name}
Error message
Invalid integer value: {value!r} for {field_name} What it means
interpret_int_env converts an env var string with int(value); a ValueError is caught and re-raised as EnvironmentVarValueError with the field name. This gives a clear, field-attributed error instead of a bare Python conversion failure.
Source
Thrown at packages/reflex-base/src/reflex_base/environment.py:96
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:
msg = f"Invalid integer value: {value!r} for {field_name}"
raise EnvironmentVarValueError(msg) from ve
def interpret_float_env(value: str, field_name: str) -> float:
"""Interpret a float 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 float(value)
except ValueError as ve:View on GitHub (pinned to 45b8ed5ab7)
Solutions
- Provide a clean integer string, e.g. PORT=8080
- If decimals are valid, change the field annotation to float
- Remove units/suffixes from the value
Example fix
# before TIMEOUT=10s # field: int # after TIMEOUT=10
Defensive patterns
Strategy: validation
Validate before calling
if not re.fullmatch(r"[+-]?\d+", raw.strip()):
raise SystemExit(f"PORT must be an integer, got {raw!r}") Type guard
def is_valid_int_env(v: str) -> bool:
try:
int(v)
return True
except ValueError:
return False Try / catch
except EnvironmentVarValueError:
value = 8000 # documented default Prevention
- Reject values with units or decimals for int fields
- Linter/CI check on numeric env vars in your deployment repo
When it happens
Trigger: An int-typed config field receives a non-integer string: PORT=8080a, TIMEOUT=10s, or a float string TIMEOUT=1.5 (int() rejects it, unlike float fields).
Common situations: Units accidentally included ('10s'), copy-paste from a URL, or decimal values in an int field after a type change.
Related errors
- Invalid boolean 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/1008ef348b3737f2.
Report an issue: GitHub.