reflex-dev/reflex · error · AttributeError

HybridProperty has no getter function

Error message

HybridProperty has no getter function

What it means

When a HybridProperty is used in a frontend (var) context via _get_var, Reflex first tries a custom var function set with @<name>.var; otherwise it falls back to the property's getter (fget). If neither exists (fget is None, e.g. a property defined with only a setter), AttributeError is raised.

Source

Thrown at packages/reflex-base/src/reflex_base/vars/hybrid_property.py:85

        ``ObjectVar`` (for attribute access on an object var, e.g. ``State.info.a_b``).
        Attribute access on ``owner`` inside the getter/var function resolves to Vars.

        Args:
            owner: The class or var the property is accessed on.

        Returns:
            The frontend Var for the property.

        Raises:
            AttributeError: If the property has no getter function and no var function is set.
        """
        if self._var is not None:
            # Call custom var function if set
            return self._var(owner)
        # Call the property getter function if no custom var function is set
        if self.fget is None:
            msg = "HybridProperty has no getter function"
            raise AttributeError(msg)
        return self.fget(owner)

    @override
    def __get__(self, instance: Any, owner: type | None = None, /) -> Any:
        """Get the value of the property.

        On an instance, return the getter's value. At the class level, return a
        frontend Var only when accessed on a state (whose class attributes are
        vars); on any other class there is no var context, so return the
        descriptor itself, like a normal property. Note that var access on a
        nested object (e.g. ``State.info.a_b``) does not go through ``__get__`` —
        it is resolved by ``ObjectVar.__getattr__`` via ``_get_var``.

        Args:
            instance: The instance of the class accessing this property.
            owner: The class that this descriptor is attached to.

        Returns:

View on GitHub (pinned to 45b8ed5ab7)

Solutions

  1. Add a getter function to the hybrid property (def the body under @rx.hybrid_property).
  2. Or supply an explicit frontend implementation with @<property_name>.var so _get_var uses it instead of fget.
  3. If the property is intentionally write-only, don't reference it in frontend code.

Example fix

# before
class State(rx.State):
    @rx.hybrid_property
    def value(self): ...
    @value.setter
    def value(self, v): self._v = v
# later: rx.text(State.value)  -> AttributeError

# after
class State(rx.State):
    @rx.hybrid_property
    def value(self):
        return self._v
    @value.setter
    def value(self, v): self._v = v
Defensive patterns

Strategy: type-guard

Validate before calling

prop = State.__dict__.get("value")
assert getattr(prop, "fget", None) is not None or getattr(prop, "_var", None) is not None

Type guard

def hybrid_has_getter_or_var(p) -> bool:
    return p.fget is not None or p._var is not None

Prevention

When it happens

Trigger: Declaring a hybrid property with no getter — only a setter or deleter — and then referencing it in the frontend or calling .var on it; or manually constructing HybridProperty(fset=...) without fget.

Common situations: Write-only style properties converted to hybrid_property; property factories that conditionally omit the getter; refactoring where the getter was accidentally deleted but setters remained.

Related errors


AI-assisted analysis of reflex-dev/reflex@45b8ed5ab7 (2026-08-28). Data as JSON: /api/errors/efce19628b501a14. Report an issue: GitHub.