[ENTERPRISE] Issue after upgrade 0.8.0 for ag-grid components
We have upgraded reflex to 0.8.0 and using reflex-enterprise 0.3.0. Suddenly, it started to get an error message and it looks like because of ag-grid components.
TypeError: Subscripted generics cannot be used with class and instance checks Traceback root is in: File ".../ag_grid/resources/base.py", line 80 elif not isinstance(return_dict[key], js_types):
And this is triggered through Reflex’s serialization chain: LiteralVar.create(element)._get_all_var_data() → .serialize(value) → .dict() → _process_js_expressions()
Expected behavior
What should have happened?
Attached errors occurs when run the code. Grid solution does not work as expected. Especially drop down in the grid line is not shown as expected.
Steps to reproduce (if applicable)
Example usage:
column_defs_detail_create = [
....
ag_grid.column_def(
field="code",
header_name="Code",
filter=ag_grid.filters.text,
editable=True,
cell_data_type="select",
cell_editor=ag_grid.editors.select,
cellEditorParams={"values": State.codeids}, # id list
refData=State.codes, # dict for id and codes
),
ag_grid.column_def(
field="name",
header_name="Name",
editable=False,
filter=ag_grid.filters.text,
cell_editor=ag_grid.editors.text,
),....]
ag_grid(
id="ag_grid_detail",
row_data=State.detaillist,
column_defs=column_defs_detail,
theme="quartz",
row_selection="multiple",
pagination=True,
pagination_page_size=5,
pagination_page_size_selector=[5, 10, 15],
on_cell_value_changed=State.handle_detail_grid_cell_value_changed,
on_selection_changed=State.handle_detail_grid_selection,
width="100%", # Ensure full width
height="37vh", # Allow grid to fill available height
),
Environment
-
Reflex Version: Reflex Enterprise: 0.3.0 Reflex: 0.8.0 Reflex-Ag-Grid: latest (0.0.11)
-
Python Version:
- Python versions tested: 3.11.13 & 3.13.5
-
OS: OS: macOS ARM (Apple Silicon)
-
Browser:
- Tried with: Safari Google Chrome Zen Browser
Please provide a code snippet that allow to reproduce the problem, your current code snippet is not valid code.
I probably cannot provide my full code but maybe this partial codes can help.
The issue is when I try with versions it works:
reflex==0.7.13
reflex_enterprise==0.1.2
When I try it with versions it does not work. Main error is : Subscripted generics cannot be used with class and instance checks latest reflex reflex_enterprise==0.3.0
WhenI try it with versions ag_grid gets error when I click on drop down. latest reflex reflex_enterprise==0.1.2
column_defs_detail_display = [
ag_grid.column_def(
field="inventory_type_id",
header_name="Inv. Type",
filter=ag_grid.filters.text,
editable=False,
cell_data_type="select",
cell_editor=ag_grid.editors.select,
cellEditorParams={"values": InvoiceState.detailtypelist},
refData=InvoiceState.detailtypes,
),
ag_grid.column_def(
field = '' ......),.......
]
ag_grid(
id="ag_grid",
row_data=row_data,
column_defs=column_defs_detail,
theme="quartz",
row_selection="multiple",
pagination=True,
pagination_page_size=5,
pagination_page_size_selector=[5, 10, 15],
on_cell_value_changed=state.handle_detail_grid_cell_value_changed,
on_selection_changed=state.handle_detail_grid_selection,
width="100%", # Ensure full width
height="37vh", # Allow grid to fill available height
),
Above part built the grid and here I use below data for preparing dropdown list with types
self.detailtypes = {type.id: type.name for type, in fetched_types}
self.detailtypelist = list(self.detailtypes.keys())
print("TYPES", self.detailtypes)
print("LIST", self.detailtypelist)
When I print: TYPES {4: 'Project', 5: 'Service', 6: 'Inventory'} LIST[4, 5, 6]
Here is the error when I try reflex 0.8.8 and reflex enterprise 0.3.0a2
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/Users//Documents/GitHub/noverp/.venv/bin/reflex", line 7, in <module>
sys.exit(cli())
~~~^^
File "/Users//Documents/GitHub/noverp/.venv/lib/python3.13/site-packages/click/core.py", line 1442, in __call__
return self.main(*args, **kwargs)
~~~~~~~~~^^^^^^^^^^^^^^^^^
File "/Users//Documents/GitHub/noverp/.venv/lib/python3.13/site-packages/click/core.py", line 1363, in main
rv = self.invoke(ctx)
File "/Users//Documents/GitHub/noverp/.venv/lib/python3.13/site-packages/click/core.py", line 1830, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
File "/Users//Documents/GitHub/noverp/.venv/lib/python3.13/site-packages/click/core.py", line 1226, in invoke
return ctx.invoke(self.callback, **ctx.params)
~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users//Documents/GitHub/noverp/.venv/lib/python3.13/site-packages/click/core.py", line 794, in invoke
return callback(*args, **kwargs)
File "/Users//Documents/GitHub/noverp/.venv/lib/python3.13/site-packages/reflex/reflex.py", line 345, in run
_run(
~~~~^
constants.Env.DEV if env == constants.Env.DEV else constants.Env.PROD,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...<4 lines>...
backend_host,
^^^^^^^^^^^^^
)
^
File "/Users//Documents/GitHub/noverp/.venv/lib/python3.13/site-packages/reflex/reflex.py", line 219, in _run
compile_future.result()
~~~~~~~~~~~~~~~~~~~~~^^
File "/opt/homebrew/Cellar/[email protected]/3.13.7/Frameworks/Python.framework/Versions/3.13/lib/python3.13/concurrent/futures/_base.py", line 456, in result
return self.__get_result()
~~~~~~~~~~~~~~~~~^^
File "/opt/homebrew/Cellar/[email protected]/3.13.7/Frameworks/Python.framework/Versions/3.13/lib/python3.13/concurrent/futures/_base.py", line 401, in __get_result
raise self._exception
TypeError: Subscripted generics cannot be used with class and instance checks
Please provide a code snippet that allow to reproduce the problem, your current code snippet is not valid code.
Could you please check my last response? I only need to understand how I can use it.
@ozgulkah can you provide a reproducer? it's hard for me to guess where the problem is without the complete picture. With the code snips provided, I would have to spend at least an hour to get something that actually runs to investigate the problem you're having.
my suggestion is
- make a new reflex app:
reflex init - copy a minimal state and minimal grid that reproduces your issue in a single python module
- post the full module here that i can copy into a new project and run
if you do this, then we can reproduce the issue and make a fix (either in reflex or reflex-enterprise).
@masenf , thanks for the suggestion. Actually, I have found the problem and resolved it with a workaround. However, I wanted to share because it might be needed for other solutions as well.
Here, I got a template from reflex and added my grid. The issue is because of this editable parameter which I filled via dynamic variable from state class:
ag_grid.column_def(
field="type_id",
header_name="Type",
filter=ag_grid.filters.text,
editable=TestState.editable, # here I used variable based dynamic value
cell_data_type="select",
cell_editor=ag_grid.editors.select,
cell_editor_params={"values": TestState.typelist},
refData=TestState.types,
),
As a workaround I have added rx.cond on top of column_defs_detail_create = [] so I generated two different column def based on editable True or False. However, it seems I cannot use it directly as a parameter value.
Here the files: