{"record":{"id":"bff2dba968244afc","repo":"reflex-dev/reflex","slug":"the-component-child-name-can-only-be-a-child-o","errorCode":null,"errorMessage":"The component `{child_name}` can only be a child of the components: {valid_parent_list}. Got `{comp_name}` instead.","messagePattern":"The component `(.+?)` can only be a child of the components: (.+?)\\. Got `(.+?)` instead\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"warning","filePath":"packages/reflex-base/src/reflex_base/components/component.py","lineNumber":1643,"sourceCode":"            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                ])\n                msg = f\"The component `{child_name}` can only be a child of the components: {valid_parent_list}. Got `{comp_name}` instead.\"\n                raise ValueError(msg)\n\n        for child in children:\n            validate_child(child)\n\n    @staticmethod\n    def _get_vars_from_event_triggers(\n        event_triggers: dict[str, EventChain | Var],\n    ) -> Iterator[tuple[str, list[Var]]]:\n        \"\"\"Get the Vars associated with each event trigger.\n\n        Args:\n            event_triggers: The event triggers from the component instance.\n\n        Yields:\n            tuple of (event_name, event_vars)\n        \"\"\"\n        for event_trigger, event in event_triggers.items():\n            if isinstance(event, Var):","sourceCodeStart":1625,"sourceCodeEnd":1661,"githubUrl":"https://github.com/reflex-dev/reflex/blob/45b8ed5ab735f8a56bbb09a42384f030eb0208e7/packages/reflex-base/src/reflex_base/components/component.py#L1625-L1661","documentation":"During serialization, Reflex pickles each state and warns (or raises StateTooLargeError in RAISE perf mode) when the pickle exceeds a size threshold, because huge states slow every event round-trip.","triggerScenarios":"A state holding large blobs (base64 files, big lists, images) is pickled and exceeds the threshold; behavior depends on REFLEX_PERF_MODE: WARN logs once, RAISE throws StateTooLargeError.","commonSituations":"Storing uploaded file contents in state vars; accumulating unbounded lists/dicts in state across events; enabling REFLEX_PERF_MODE=raise in CI to catch regressions.","solutions":["Move large data out of state (object storage / filesystem, keep only a URL or id in state)","Trim/cap collections stored in state (e.g. keep last N chat messages)","If the size is intentional, set REFLEX_PERF_MODE=warn (default) or off to silence"],"exampleFix":"// before\nclass State(rx.State):\n    file_data: str = \"\"  # base64 blob\n// after\nclass State(rx.State):\n    file_url: str = \"\"  # uploaded to storage","handlingStrategy":"validation","validationCode":"import pickle\nsize = len(pickle.dumps(state))\nif size > threshold:\n    trim_state()  # prune large fields before continuing","typeGuard":null,"tryCatchPattern":"try:\n    await state._serialize()\nexcept StateTooLargeError:\n    await cleanup_large_fields()","preventionTips":["Never store file blobs in state; store URLs","Cap growing collections in state","Run with REFLEX_PERF_MODE=warn in CI to catch size regressions"],"tags":["reflex","performance","state-size","serialization"],"backgroundTag":"payload-too-large","analyzedSha":"45b8ed5ab735f8a56bbb09a42384f030eb0208e7","analyzedAt":"2026-08-28T19:25:27.644Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}