-
Couldn't load subscription status.
- Fork 4.5k
Description
Issue Summary
We tried to upgrade from v10.1.0 to v25.8.0
When using Redash dashboards, certain widget entries in the widgets PostgreSQL table contain empty JSON objects ({}) in the options column. This causes unexpected rendering or layout inconsistencies within the dashboard interface. Specifically, widgets with empty options fail to display correctly until their configuration is manually updated in the database.
The issue was the following:
Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1276, in _execute_context self.dialect.do_execute( File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py", line 608, in do_execute cursor.execute(statement, parameters) psycopg2.errors.NotNullViolation: null value in column "options" of relation "widgets" violates not-null constraint DETAIL: Failing row contains (2019-12-11 15:12:50.156141+00, 2019-12-11 15:12:50.156141+00, 300, 1996, , 2, null, 52). The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/app/./manage.py", line 9, in <module> manager() File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1130, in __call__ return self.main(*args, **kwargs) File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1055, in main rv = self.invoke(ctx) File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1657, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1657, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1404, in invoke return ctx.invoke(self.callback, **ctx.params) File "/usr/local/lib/python3.10/site-packages/click/core.py", line 760, in invoke return __callback(*args, **kwargs) File "/usr/local/lib/python3.10/site-packages/click/decorators.py", line 26, in new_func return f(get_current_context(), *args, **kwargs) File "/usr/local/lib/python3.10/site-packages/flask/cli.py", line 357, in decorator return __ctx.invoke(f, *args, **kwargs) File "/usr/local/lib/python3.10/site-packages/click/core.py", line 760, in invoke return __callback(*args, **kwargs) File "/usr/local/lib/python3.10/site-packages/flask_migrate/cli.py", line 134, in upgrade _upgrade(directory, revision, sql, tag, x_arg) File "/usr/local/lib/python3.10/site-packages/flask_migrate/__init__.py", line 95, in wrapped f(*args, **kwargs) File "/usr/local/lib/python3.10/site-packages/flask_migrate/__init__.py", line 280, in upgrade command.upgrade(config, revision, sql=sql, tag=tag) File "/usr/local/lib/python3.10/site-packages/alembic/command.py", line 406, in upgrade script.run_env() File "/usr/local/lib/python3.10/site-packages/alembic/script/base.py", line 586, in run_env util.load_python_file(self.dir, "env.py") File "/usr/local/lib/python3.10/site-packages/alembic/util/pyfiles.py", line 95, in load_python_file module = load_module_py(module_id, path) File "/usr/local/lib/python3.10/site-packages/alembic/util/pyfiles.py", line 113, in load_module_py spec.loader.exec_module(module) # type: ignore File "<frozen importlib._bootstrap_external>", line 883, in exec_module File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed File "/app/migrations/env.py", line 93, in <module> run_migrations_online() File "/app/migrations/env.py", line 85, in run_migrations_online context.run_migrations() File "<string>", line 8, in run_migrations File "/usr/local/lib/python3.10/site-packages/alembic/runtime/environment.py", line 946, in run_migrations self.get_context().run_migrations(**kw) File "/usr/local/lib/python3.10/site-packages/alembic/runtime/migration.py", line 623, in run_migrations step.migration_fn(**kw) File "/app/migrations/versions/db0aca1ebd32_12_column_dashboard_layout.py", line 20, in upgrade op.execute(""" File "<string>", line 8, in execute File "<string>", line 3, in execute File "/usr/local/lib/python3.10/site-packages/alembic/operations/ops.py", line 2551, in execute return operations.invoke(op) File "/usr/local/lib/python3.10/site-packages/alembic/operations/base.py", line 442, in invoke return fn(self, operation) File "/usr/local/lib/python3.10/site-packages/alembic/operations/toimpl.py", line 236, in execute_sql operations.migration_context.impl.execute( File "/usr/local/lib/python3.10/site-packages/alembic/ddl/impl.py", line 254, in execute self._exec(sql, execution_options) File "/usr/local/lib/python3.10/site-packages/alembic/ddl/impl.py", line 247, in _exec return conn.execute(construct, params) File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1011, in execute return meth(self, multiparams, params) File "/usr/local/lib/python3.10/site-packages/sqlalchemy/sql/elements.py", line 298, in _execute_on_connection return connection._execute_clauseelement(self, multiparams, params) File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1124, in _execute_clauseelement ret = self._execute_context( File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1316, in _execute_context self._handle_dbapi_exception( File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1510, in _handle_dbapi_exception util.raise_( File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/compat.py", line 182, in raise_ raise exception File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1276, in _execute_context self.dialect.do_execute( File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py", line 608, in do_execute cursor.execute(statement, parameters) sqlalchemy.exc.IntegrityError: (psycopg2.errors.NotNullViolation) null value in column "options" of relation "widgets" violates not-null constraint DETAIL: Failing row contains (2019-12-11 15:12:50.156141+00, 2019-12-11 15:12:50.156141+00, 300, 1996, , 2, null, 52). [SQL: UPDATE widgets SET options = jsonb_set(options, '{position,col}', to_json((options->'position'->>'col')::int * 2)::jsonb); UPDATE widgets SET options = jsonb_set(options, '{position,sizeX}', to_json((options->'position'->>'sizeX')::int * 2)::jsonb); ] (Background on this error at: http://sqlalche.me/e/13/gkpj)
Steps to Reproduce
- Open a dashboard that contains widgets with an empty options column in the database.
- Observe that the widgets are missing or fail to render.
- Check the database and confirm that some widgets have options = '{}'.
We have created a temporary fix that applies a proper rendering of the affected widgets in-place:
UPDATE widgets
SET options = '{"isHidden": false, "position": {"autoHeight": false, "sizeX": 1, "sizeY": 5, "minSizeX": 1, "maxSizeX": 6, "minSizeY": 1, "maxSizeY": 1000, "col": 3, "row": 8}, "parameterMappings": {}}'
where dashboard_id=<id>;
Any other info e.g. Why do you consider this to be a bug? What did you expect to happen instead?
Technical details:
- Redash Version: 10.1.0
- Browser/OS:
- How did you install Redash: Kubernetes/Docker