Textualize/textual · error · ReactiveError

Unable to bind data; {reactive.owner.__name__} is not define

Error message

Unable to bind data; {reactive.owner.__name__} is not defined on {parent.__class__.__name__}.

What it means

Thrown by DOMNode.data_bind when the reactive attribute being bound was defined on a different owner class than the parent object passed to the bind. Textual verifies that the reactive descriptor's owner (the class where @reactive was declared) matches the parent's class before wiring the connection.

Source

Thrown at src/textual/dom.py:341

        Returns:
            Self.
        """
        _rich_traceback_omit = True

        parent = active_message_pump.get()

        if self._reactive_connect is None:
            self._reactive_connect = {}
        bind_vars = {**{reactive.name: reactive for reactive in reactives}, **bind_vars}
        for name, reactive in bind_vars.items():
            if name not in self._reactives:
                raise ReactiveError(
                    f"Unable to bind non-reactive attribute {name!r} on {self}"
                )
            if isinstance(reactive, Reactive) and not isinstance(
                parent, reactive.owner
            ):
                raise ReactiveError(
                    f"Unable to bind data; {reactive.owner.__name__} is not defined on {parent.__class__.__name__}."
                )
            self._reactive_connect[name] = (parent, reactive)
        if self._is_mounted:
            self._initialize_data_bind()
        else:
            self.call_later(self._initialize_data_bind)
        return self

    def _initialize_data_bind(self) -> None:
        """initialize a data binding.

        Args:
            compose_parent: The node doing the binding.
        """
        if not self._reactive_connect:
            return
        for variable_name, (compose_parent, reactive) in self._reactive_connect.items():

View on GitHub (pinned to 06dbeef4bb)

Solutions

  1. Ensure the parent object passed to data_bind is an instance of (or inherits from) the class where the reactive attribute is declared with @reactive
  2. If the parent is a plain object, either make the attribute a textual.reactive on a DOMNode subclass or use watch methods/manual refresh instead of data_bind
  3. Check the `data-bind` selector/attribute path in TSS points at a widget class that actually defines that reactive

Example fix

# before
class MyApp(App):
    count = reactive(0)

widget.data_bind(some_plain_obj)  # ReactiveError

# after
class MyApp(App):
    count = reactive(0)

widget.data_bind(my_app_instance)  # owner matches MyApp
Defensive patterns

Strategy: validation

Validate before calling

from textual.reactive import Reactive

def can_bind(parent, attr: str) -> bool:
    for klass in type(parent).__mro__:
        reactive = klass.__dict__.get(attr)
        if isinstance(reactive, Reactive):
            return isinstance(parent, reactive.owner)
    return False

assert can_bind(parent_obj, 'count'), 'owner mismatch'

Type guard

def has_reactive_owner(parent: object, attr: str) -> bool:
    return any(
        isinstance(v, Reactive) and isinstance(parent, v.owner)
        for k in type(parent).__mro__ for v in vars(k).values()
        if k is not object
    ) if hasattr(type(parent), '__mro__') else False

Try / catch

from textual.reactive import ReactiveError
try:
    widget.data_bind(parent)
except ReactiveError as e:
    log.warning(f'bind failed: {e}')  # fall back to manual watch/refresh

Prevention

When it happens

Trigger: Calling widget.data_bind(parent) or using the `data-bind` CSS pattern where the referenced attribute is a reactive defined on a class other than parent's class (e.g. binding a widget's reactive to a plain object, or to a subclass/superclass that doesn't inherit the reactive's owner).

Common situations: Binding to a dataclass or plain Python object instead of a DOMNode with @reactive attributes; refactoring reactives between classes while keeping old data-bind declarations; typos in the attribute name resolving to a similarly-named reactive on another class.

Related errors


AI-assisted analysis of Textualize/textual@06dbeef4bb (2026-08-27). Data as JSON: /api/errors/ce07ccf2dec5b6a8. Report an issue: GitHub.