reflex-dev/reflex · error · VarValueError
Cannot determine dependencies in fetched state {local_name!r
Error message
Cannot determine dependencies in fetched state {local_name!r}: {local_value!r} is not a BaseState. What it means
During automatic dependency tracking of a cached computed var, reflex found a local variable that looks like a fetched state reference but is not a BaseState subclass. Only state classes can be tracked as dependencies.
Source
Thrown at packages/reflex-base/src/reflex_base/vars/dep_tracking.py:76
local_name: str | None = None,
) -> type[BaseState]:
"""Assert that a local variable is a BaseState subclass.
Args:
local_value: The value of the local variable to check.
local_name: The name of the local variable to check.
Returns:
The local variable value if it is a BaseState subclass.
Raises:
VarValueError: If the object is not a BaseState subclass.
"""
from reflex.state import BaseState
if not isinstance(local_value, type) or not issubclass(local_value, BaseState):
msg = f"Cannot determine dependencies in fetched state {local_name!r}: {local_value!r} is not a BaseState."
raise VarValueError(msg)
return local_value
@dataclasses.dataclass
class DependencyTracker:
"""State machine for identifying state attributes that are accessed by a function."""
func: FunctionType | CodeType = dataclasses.field()
state_cls: type[BaseState] = dataclasses.field()
dependencies: dict[str, set[str]] = dataclasses.field(default_factory=dict)
scan_status: ScanStatus = dataclasses.field(default=ScanStatus.SCANNING)
top_of_stack: str | None = dataclasses.field(default=None)
tracked_locals: dict[str, type[BaseState] | ModuleType] = dataclasses.field(
default_factory=dict
)View on GitHub (pinned to 45b8ed5ab7)
Solutions
- Make the referenced object an actual rx.State subclass
- Update the computed var to reference the correct state class
Defensive patterns
Strategy: type-guard
Validate before calling
import reflex as rx assert isinstance(obj, type) and issubclass(obj, rx.State), 'must be a State subclass'
Type guard
def is_state_class(obj) -> bool:
import reflex as rx
return isinstance(obj, type) and issubclass(obj, rx.State) Prevention
- Keep state classes as rx.State subclasses
- Don't convert state classes to plain dataclasses/modules
When it happens
Trigger: Inside a cached computed var, referencing something via get_state-like patterns where the local resolves to a module, function, or instance rather than a State class.
Common situations: Refactoring state classes into plain classes/modules while cached computed vars still reference them; naming a non-state class the same as a former state class.
Related errors
- UntypedComputedVarError(var_name=fget.__name__)
- ComputedVar dependencies must be Var instances or var names
- ComputedVar dependencies must be Var instances with a state
- {local_name!r} is not tracked in the current scope.
- Cached var {self!s} cannot access arbitrary state via `{inst
AI-assisted analysis of reflex-dev/reflex@45b8ed5ab7 (2026-08-28).
Data as JSON: /api/errors/18f9ed224be7bf59.
Report an issue: GitHub.