{"record":{"id":"954b4ad80959b623","repo":"reflex-dev/reflex","slug":"invalid-event-chain-value-s-of-type-value-var","errorCode":null,"errorMessage":"Invalid event chain: {value!s} of type {value._var_type}","messagePattern":"Invalid event chain: (.+?) of type (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"packages/reflex-base/src/reflex_base/event/__init__.py","lineNumber":911,"sourceCode":"                if event_chain_kwargs:\n                    warnings.warn(\n                        f\"event_chain_kwargs {event_chain_kwargs!r} are ignored for \"\n                        \"EventChainVar values.\",\n                        stacklevel=2,\n                    )\n                return value\n            if isinstance(value, (EventVar, FunctionVar)):\n                value = [value]\n            elif safe_issubclass(value._var_type, (EventChain, EventSpec)):\n                return cls.create(\n                    value=value.guess_type(),\n                    args_spec=args_spec,\n                    key=key,\n                    **event_chain_kwargs,\n                )\n            else:\n                msg = f\"Invalid event chain: {value!s} of type {value._var_type}\"\n                raise ValueError(msg)\n        elif isinstance(value, EventChain):\n            # Trust that the caller knows what they're doing passing an EventChain directly\n            return value\n\n        # If the input is a single event handler, wrap it in a list.\n        if isinstance(value, (EventHandler, EventSpec)):\n            value = [value]\n\n        events: list[EventSpec | EventVar | FunctionVar] = []\n\n        # If the input is a list of event handlers, create an event chain.\n        if isinstance(value, list):\n            for v in value:\n                if isinstance(v, (EventHandler, EventSpec)):\n                    # Call the event handler to get the event.\n                    events.append(call_event_handler(v, args_spec, key=key))\n                elif isinstance(v, (EventVar, EventChainVar)):\n                    events.append(v)","sourceCodeStart":893,"sourceCodeEnd":929,"githubUrl":"https://github.com/reflex-dev/reflex/blob/45b8ed5ab735f8a56bbb09a42384f030eb0208e7/packages/reflex-base/src/reflex_base/event/__init__.py#L893-L929","documentation":"EventChain.create accepts handlers, EventSpecs, EventChains, lists of those, or lambdas; if the value is a Var (has _var_type) it falls through to this branch and is rejected with its type, because a Var is data, not an event chain.","triggerScenarios":"Passing a Var (e.g. State.some_var or a computed Var) where an event trigger is expected: on_click=State.items, on_click=rx.cond(..., a, b) misuse, or a lambda that returns a Var.","commonSituations":"Assigning a Var to an event prop by accident (missing parentheses on an event call), or a lambda returning a Var instead of an event.","solutions":["Ensure the value is an event handler call, EventSpec, EventChain, or a lambda returning those","If a lambda returns a Var, wrap the logic so it returns events (e.g. use rx.cond at the component level, not inside the event slot)","Check for a missing () on the handler invocation"],"exampleFix":"# before\nrx.button('Go', on_click=State.count)  # a Var\n# after\nrx.button('Go', on_click=State.increment)","handlingStrategy":"type-guard","validationCode":"from reflex_base.event import EventHandler, EventSpec, EventChain\n\ndef is_event_chain_value(v) -> bool:\n    return isinstance(v, (EventHandler, EventSpec, EventChain, list, tuple)) and not hasattr(v, '_var_type')","typeGuard":"def is_event_trigger(v) -> TypeGuard[object]: return isinstance(v, (EventHandler, EventSpec, EventChain)) or callable(v)","tryCatchPattern":null,"preventionTips":["Never assign a bare Var to an event prop","Review on_* props for missing () when calling handlers"],"tags":["reflex","event-chain","var-misuse","validation"],"backgroundTag":"invalid-event-handler-binding","analyzedSha":"45b8ed5ab735f8a56bbb09a42384f030eb0208e7","analyzedAt":"2026-08-28T19:25:27.644Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}