reflex-dev/reflex · warning
event_chain_kwargs {event_chain_kwargs!r} are ignored for Ev
Error message
event_chain_kwargs {event_chain_kwargs!r} are ignored for EventChainVar values. What it means
Reflex's event spec factory (EventSpec.create) emits this Python warning when you pass event_chain_kwargs (e.g. event_loader, or chain-level args like stop_propagation/prevent_default on the chain) together with an already-built EventChainVar. For literal prebuilt chains there is nowhere to attach those kwargs, so they are silently ignored and you are warned.
Source
Thrown at packages/reflex-base/src/reflex_base/event/__init__.py:894
value: The value to create the event chain from.
args_spec: The args_spec of the event trigger being bound.
key: The key of the event trigger being bound.
**event_chain_kwargs: Additional kwargs to pass to the EventChain constructor.
Returns:
The event chain.
Raises:
ValueError: If the value is not a valid event chain.
"""
# If it's an event chain var, return it.
if isinstance(value, Var):
# Only pass through literal/prebuilt chains. Other EventChainVar values may be
# FunctionVars cast with `.to(EventChain)` and still need wrapping so
# event_chain_kwargs can compose onto the resulting chain.
if isinstance(value, LiteralEventChainVar):
if event_chain_kwargs:
warnings.warn(
f"event_chain_kwargs {event_chain_kwargs!r} are ignored for "
"EventChainVar values.",
stacklevel=2,
)
return value
if isinstance(value, (EventVar, FunctionVar)):
value = [value]
elif safe_issubclass(value._var_type, (EventChain, EventSpec)):
return cls.create(
value=value.guess_type(),
args_spec=args_spec,
key=key,
**event_chain_kwargs,
)
else:
msg = f"Invalid event chain: {value!s} of type {value._var_type}"
raise ValueError(msg)
elif isinstance(value, EventChain):View on GitHub (pinned to 45b8ed5ab7)
Solutions
- Move the kwargs into the chain construction site — build the chain with the desired options (e.g. rx.chain(..., stop_propagation=True) or pass event_loader where the EventChainVar is created) instead of at the trigger.
- If the kwargs are redundant for this usage, delete them; the warning confirms they have no effect.
- If you need per-trigger behavior, pass a lambda or action reference rather than a prebuilt EventChainVar, so kwargs compose onto a fresh chain.
Example fix
# before
chain = rx.action(rx.console_log('hi'))
rx.button('Go', on_click=chain, stop_propagation=True) # warns: ignored
# after
chain = rx.action(rx.console_log('hi'), stop_propagation=True)
rx.button('Go', on_click=chain) Defensive patterns
Strategy: validation
Validate before calling
from reflex.vars import Var
def is_prebuilt_chain(v) -> bool:
return isinstance(v, Var) and getattr(v, '_var_type', None).__name__ in ('EventChain',)
# only pass event_chain_kwargs when NOT passing a prebuilt EventChainVar
kwargs = {} if is_prebuilt_chain(on_click) else {'stop_propagation': True} Type guard
from reflex.event import EventChain
def is_literal_event_chain_var(v) -> bool:
return f'{type(v).__module__}.{type(v).__name__}' == 'reflex.event.LiteralEventChainVar' Prevention
- Apply chain-level options (stop_propagation, prevent_default, event_loader) where the chain is created, not at the trigger site.
- Pass lambdas/state actions to on_click when you need per-trigger kwargs.
- Treat this warning as a signal that your kwargs are no-ops — remove them instead of silencing it.
When it happens
Trigger: Calling rx.event.run_script(...)/event helpers or wiring an EventChainVar (e.g. a value already created with rx.action(...) / a LiteralEventChainVar) into an event trigger while also passing event_chain_kwargs such as {'event_loader': ...} or stopPropagation-style chain options, e.g. rx.button('Go', on_click=my_chain_var, ...custom kwargs...) via EventSpec.create / add_args / _as_event_spec.
Common situations: Migrating from passing a lambda/state action (which builds the chain lazily and accepts kwargs) to passing a prebuilt Var chain; sharing one prebuilt EventChainVar across components but trying to give each usage different chain kwargs; using .to(EventChain) casts.
Related errors
- Unexpected event type, {type(e)}.
- Invalid event chain: {value!s} of type {value._var_type}
- Invalid event: {v}
- Invalid event chain: {value}
- Unknown mime type for {image} {image_format}. Defaulting to
AI-assisted analysis of reflex-dev/reflex@45b8ed5ab7 (2026-08-28).
Data as JSON: /api/errors/0980f892b0743d3d.
Report an issue: GitHub.