{"record":{"id":"8188bf7e76557277","repo":"reflex-dev/reflex","slug":"output-includes-value-s-which-will-be-displayed","errorCode":null,"errorMessage":"Output includes {value!s} which will be displayed as a string. If you are calling `str` on a Var, consider using .to_string() instead.","messagePattern":"Output includes (.+?) which will be displayed as a string\\. If you are calling `str` on a Var, consider using \\.to_string\\(\\) instead\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"packages/reflex-components-core/src/reflex_components_core/base/bare.py","lineNumber":49,"sourceCode":"\ndef validate_str(value: str):\n    \"\"\"Validate a string value.\n\n    Args:\n        value: The value to validate.\n\n    Raises:\n        ValueError: If the value is a Var and the performance mode is set to raise.\n    \"\"\"\n    perf_mode = get_performance_mode()\n    if perf_mode != PerformanceMode.OFF and value.startswith(\"reflex___state\"):\n        if perf_mode == PerformanceMode.WARN:\n            logger.warning(\n                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.\"\n            )\n        elif perf_mode == PerformanceMode.RAISE:\n            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.\"\n            raise ValueError(msg)\n\n\ndef _components_from_var(var: Var) -> Sequence[BaseComponent]:\n    var_data = var._get_all_var_data()\n    return var_data.components if var_data else ()\n\n\nclass Bare(Component):\n    \"\"\"A component with no tag.\"\"\"\n\n    contents: Var[Any]\n\n    @classmethod\n    def create(cls, contents: Any) -> Component:\n        \"\"\"Create a Bare component, with no tag.\n\n        Args:\n            contents: The contents of the component.","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/reflex-dev/reflex/blob/45b8ed5ab735f8a56bbb09a42384f030eb0208e7/packages/reflex-components-core/src/reflex_components_core/base/bare.py#L31-L67","documentation":"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.","triggerScenarios":"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).","commonSituations":"Mixing f-strings with State Vars like f\"Count: {State.count}\" inside bare/rx.el output, instead of using Var concatenation or .to_string().","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"],"exampleFix":"// before\nrx.el.div(f\"Count: {State.count}\")\n\n// after\nrx.el.div(\"Count: \", State.count.to_string())","handlingStrategy":"validation","validationCode":"# never interpolate Vars in f-strings inside rx.el children\nchildren = [\"Count: \", State.count.to_string()]","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use Var concatenation and .to_string() instead of f-strings","Keep perf_mode strict in CI to catch coercions early"],"tags":["var-coercion","performance","rendering"],"backgroundTag":"unsafe-var-string-coercion","analyzedSha":"45b8ed5ab735f8a56bbb09a42384f030eb0208e7","analyzedAt":"2026-08-28T19:25:27.644Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}