reflex-dev/reflex · error · ValueError
Output includes {value!s} which will be displayed as a strin
Error message
Output includes {value!s} which will be displayed as a string. If you are calling `str` on a Var, consider using .to_string() instead. What it means
rx.el bare rendering validates that dynamic output is not a raw Var being coerced through str(), which would serialize a Var object instead of its runtime value. In RAISE performance mode this validation raises ValueError; in WARN mode it logs the same message.
Source
Thrown at packages/reflex-components-core/src/reflex_components_core/base/bare.py:49
def validate_str(value: str):
"""Validate a string value.
Args:
value: The value to validate.
Raises:
ValueError: If the value is a Var and the performance mode is set to raise.
"""
perf_mode = get_performance_mode()
if perf_mode != PerformanceMode.OFF and value.startswith("reflex___state"):
if perf_mode == PerformanceMode.WARN:
logger.warning(
f"Output includes {value!s} which will be displayed as a string. If you are calling `str` on a Var, consider using .to_string() instead."
)
elif perf_mode == PerformanceMode.RAISE:
msg = f"Output includes {value!s} which will be displayed as a string. If you are calling `str` on a Var, consider using .to_string() instead."
raise ValueError(msg)
def _components_from_var(var: Var) -> Sequence[BaseComponent]:
var_data = var._get_all_var_data()
return var_data.components if var_data else ()
class Bare(Component):
"""A component with no tag."""
contents: Var[Any]
@classmethod
def create(cls, contents: Any) -> Component:
"""Create a Bare component, with no tag.
Args:
contents: The contents of the component.View on GitHub (pinned to 45b8ed5ab7)
Solutions
- Use Var operations: 'Count: ' + State.count.to_string()
- Or use rx.cond / rx.foreach for dynamic fragments
- Set perf_mode to PerformanceMode.WARN to downgrade to a warning if the coercion is intended
Example fix
// before
rx.el.div(f"Count: {State.count}")
// after
rx.el.div("Count: ", State.count.to_string()) Defensive patterns
Strategy: validation
Validate before calling
# never interpolate Vars in f-strings inside rx.el children children = ["Count: ", State.count.to_string()]
Prevention
- Use Var concatenation and .to_string() instead of f-strings
- Keep perf_mode strict in CI to catch coercions early
When it happens
Trigger: Calling rx.el(...)(f"{some_var}") or Bare.create with an f-string/format that str()s a Var while perf_mode is PerformanceMode.RAISE (default strict mode).
Common situations: Mixing f-strings with State Vars like f"Count: {State.count}" inside bare/rx.el output, instead of using Var concatenation or .to_string().
Related errors
AI-assisted analysis of reflex-dev/reflex@45b8ed5ab7 (2026-08-28).
Data as JSON: /api/errors/8188bf7e76557277.
Report an issue: GitHub.