{"record":{"id":"652f82d2a8e0c1de","repo":"reflex-dev/reflex","slug":"the-component-comp-name-cannot-have-child-na","errorCode":null,"errorMessage":"The component `{comp_name}` cannot have `{child_name}` as a child component","messagePattern":"The component `(.+?)` cannot have `(.+?)` as a child component","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"packages/reflex-base/src/reflex_base/components/component.py","lineNumber":1623,"sourceCode":"            child_name = type(child).__name__\n\n            # Iterate through the immediate children of fragment\n            if isinstance(child, Fragment):\n                for c in child.children:\n                    validate_child(c)\n\n            if isinstance(child, Cond):\n                validate_child(child.children[0])\n                validate_child(child.children[1])\n\n            if isinstance(child, Match):\n                for cases in child.match_cases:\n                    validate_child(cases[-1])\n                validate_child(child.default)\n\n            if self._invalid_children and child_name in self._invalid_children:\n                msg = f\"The component `{comp_name}` cannot have `{child_name}` as a child component\"\n                raise ValueError(msg)\n\n            if self._valid_children and child_name not in [\n                *self._valid_children,\n                *allowed_components,\n            ]:\n                valid_child_list = \", \".join([\n                    f\"`{v_child}`\" for v_child in self._valid_children\n                ])\n                msg = f\"The component `{comp_name}` only allows the components: {valid_child_list} as children. Got `{child_name}` instead.\"\n                raise ValueError(msg)\n\n            if child._valid_parents and all(\n                clz_name not in [*child._valid_parents, *allowed_components]\n                for clz_name in self._iter_parent_classes_names()\n            ):\n                valid_parent_list = \", \".join([\n                    f\"`{v_parent}`\" for v_parent in child._valid_parents\n                ])","sourceCodeStart":1605,"sourceCodeEnd":1641,"githubUrl":"https://github.com/reflex-dev/reflex/blob/45b8ed5ab735f8a56bbb09a42384f030eb0208e7/packages/reflex-base/src/reflex_base/components/component.py#L1605-L1641","documentation":"BaseState.get_var_value resolves a Var's runtime value by inspecting its _var_data (state name + field name). If the var isn't attached to any state, UnretrieableVarValueError is raised because there's no state instance to read from.","triggerScenarios":"Calling `await state.get_var_value(some_var)` where some_var was created standalone (e.g. `rx.Var.create(...)` or a var from a non-state context) rather than accessed via a State class attribute.","commonSituations":"Passing a raw/computed var expression (result of arithmetic or `_var_operation`) that lost state association into server-side rendering logic like ComponentState data functions.","solutions":["Pass a var accessed directly from a state class (`State.foo`) so _var_data carries state/field_name","Unwrap ToOperation vars to the original state var before calling get_var_value","Handle UnretrievableVarValueError and fetch the value from state manually"],"exampleFix":"// before\nval = await state.get_var_value(State.items.length())\n// after\nval = len(state.items)","handlingStrategy":"type-guard","validationCode":"vd = getattr(var, \"_var_data\", None)\nif vd is None or not vd.state or not vd.field_name:\n    raise ValueError(\"var not bound to a state; cannot read value\")","typeGuard":"def var_is_state_bound(var) -> bool:\n    inner = var\n    while isinstance(inner, reflex.vars.ToOperation):\n        inner = inner._original\n    vd = inner._var_data\n    return vd is not None and bool(vd.state) and bool(vd.field_name)","tryCatchPattern":"try:\n    val = await state.get_var_value(var)\nexcept UnretrievableVarValueError:\n    val = None","preventionTips":["Pass plain State.foo vars to get_var_value","Compute derived values server-side instead of passing var expressions"],"tags":["reflex","vars","runtime-value"],"backgroundTag":"var-not-bound-to-state","analyzedSha":"45b8ed5ab735f8a56bbb09a42384f030eb0208e7","analyzedAt":"2026-08-28T19:25:27.644Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}