reflex-dev/reflex · error · ValueError
Annotation of the computed var assigned to the data field sh
Error message
Annotation of the computed var assigned to the data field should be provided.
What it means
data_table needs the Python type of data to serialize pandas DataFrames correctly. If data is a computed var annotated as Any (no return annotation), Reflex cannot tell whether it is a DataFrame.
Source
Thrown at packages/reflex-components-gridjs/src/reflex_components_gridjs/datatable.py:68
Args:
*children: The children of the component.
**props: The props to pass to the component.
Returns:
The datatable component.
Raises:
ValueError: If a pandas dataframe is passed in and columns are also provided.
"""
data = props.get("data")
columns = props.get("columns")
# The annotation should be provided if data is a computed var. We need this to know how to
# render pandas dataframes.
if is_computed_var(data) and data._var_type == Any:
msg = "Annotation of the computed var assigned to the data field should be provided."
raise ValueError(msg)
if (
columns is not None
and is_computed_var(columns)
and columns._var_type == Any
):
msg = "Annotation of the computed var assigned to the column field should be provided."
raise ValueError(msg)
# If data is a pandas dataframe and columns are provided throw an error.
if (
types.is_dataframe(type(data))
or (isinstance(data, Var) and types.is_dataframe(data._var_type))
) and columns is not None:
msg = "Cannot pass in both a pandas dataframe and columns to the data_table component."
raise ValueError(msg)
# If data is a list and columns are not provided, throw an errorView on GitHub (pinned to 45b8ed5ab7)
Solutions
- Annotate the computed var: @rx.var def get_data(self) -> pd.DataFrame: ...
- Or annotate as the concrete list type you return
Example fix
# before
@rx.var
def table_data(self):
return self.df
# after
@rx.var
def table_data(self) -> pd.DataFrame:
return self.df Defensive patterns
Strategy: type-guard
Validate before calling
import inspect ret = inspect.signature(get_data.fn if hasattr(get_data, 'fn') else get_data).return_annotation assert ret is not inspect.Signature.empty, 'annotate the computed var feeding data_table'
Type guard
def computed_var_is_annotated(v: Any) -> bool:
return not (is_computed_var(v) and v._var_type is Any) Prevention
- Always annotate @rx.var return types
- Enable pyright/mypy strictness on state modules
When it happens
Trigger: @rx.var-def computed var without a return annotation passed to rx.data_table(data=...) — data._var_type is Any.
Common situations: Writing @rx.var def get_data(self): return self.df without an annotation, often after refactoring or in dynamically-typed codebases.
Related errors
- Annotation of the computed var assigned to the column field
- UntypedComputedVarError(var_name=fget.__name__)
- `@rx.memo` on `{fn.__name__}` must return `rx.Component` or
- `{handler_name}` handler should have a parameter annotated a
- MissingAnnotationError
AI-assisted analysis of reflex-dev/reflex@45b8ed5ab7 (2026-08-28).
Data as JSON: /api/errors/328c9c404db65682.
Report an issue: GitHub.