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
- Add a getter function to the hybrid property (def the body under @rx.hybrid_property).
- Or supply an explicit frontend implementation with @<property_name>.var so _get_var uses it instead of fget.
- 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
- Always define a getter body under @rx.hybrid_property.
- Keep the getter when adding setters.
- Reference hybrid properties in frontend only when a getter or .var implementation exists.
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
- Hybrid property '{self.__property_name}' of state '{state_cl
- The State var `{self!s}` of type {escape(str(self._var_type)
- ChildrenTypeError(component=cls.__name__, child=child)
- Do not override _add_style directly. Use add_style instead.
- The component `{comp_name}` cannot have `{child_name}` as a
AI-assisted analysis of reflex-dev/reflex@45b8ed5ab7 (2026-08-28).
Data as JSON: /api/errors/efce19628b501a14.
Report an issue: GitHub.