Bug description

I developed a dashboard on one Superset instance, which I recently upgraded from 4.0.1 to 4.1.2. The dashboard there works fine. But after exporting the dashboard then importing it to a new 4.1.2 instance, the dashboard gives this error on load: "Error loading chart datasources. Filters may not work correctly."

However, all charts appear to function correctly and all filters appear to work. I tried this:

  1. Delete all charts and datasets and dashboards and re-try import
  2. Make a new export and try importing it
  3. Export the problematic dashboard and then try re-importing it to the same instance
  4. Upgrade then to 4.1.3 and try re-importing dashboard

3 failed on import with this error (on 4.1.2):

(see additional context)

Additionally, the error on the dashboard seems to be because the following API call (both 4.1.2 and 4.1.3):

(see additional context)

Screenshots/recordings

No response

Superset version

4.1.3

Python version

3.10

Node version

16

Browser

Chrome

Additional context

Export/Import problem dashboard error `2025-07-23 17:12:36,507:ERROR:superset.commands.dashboard.importers.dispatcher:Error running import command Traceback (most recent call last): File "/app/superset/commands/importers/v1/init.py", line 76, in run self._import(self._configs, self.overwrite) File "/app/superset/commands/dashboard/importers/v1/init.py", line 117, in _import config = update_chart_config_dataset(config, dataset_dict) File "/app/superset/commands/utils.py", line 217, in update_chart_config_dataset query_context["form_data"]["datasource"] = dataset_uid TypeError: 'str' object does not support item assignment

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/app/superset/commands/dashboard/importers/dispatcher.py", line 57, in run command.run() File "/app/superset/utils/decorators.py", line 266, in wrapped return on_error(ex) File "/app/superset/utils/decorators.py", line 236, in on_error raise ex File "/app/superset/utils/decorators.py", line 259, in wrapped result = func(args, *kwargs) File "/app/superset/commands/importers/v1/init.py", line 80, in run raise self.import_error() from ex superset.commands.dashboard.exceptions.DashboardImportError: Import dashboard failed for an unknown reason 2025-07-23 17:12:36,508:WARNING:superset.views.error_handling:CommandException Traceback (most recent call last): File "/app/superset/commands/importers/v1/init.py", line 76, in run self._import(self._configs, self.overwrite) File "/app/superset/commands/dashboard/importers/v1/init.py", line 117, in _import config = update_chart_config_dataset(config, dataset_dict) File "/app/superset/commands/utils.py", line 217, in update_chart_config_dataset query_context["form_data"]["datasource"] = dataset_uid TypeError: 'str' object does not support item assignment

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 1484, in full_dispatch_request rv = self.dispatch_request() File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 1469, in dispatch_request return self.ensure_sync(self.view_functions[rule.endpoint])(view_args) File "/usr/local/lib/python3.10/site-packages/flask_appbuilder/security/decorators.py", line 95, in wraps return f(self, *args, kwargs) File "/app/superset/views/base_api.py", line 119, in wraps duration, response = time_function(f, self, args, kwargs) File "/app/superset/utils/core.py", line 1364, in time_function response = func(args, kwargs) File "/app/superset/utils/log.py", line 303, in wrapper value = f(*args, kwargs) File "/app/superset/views/base_api.py", line 106, in wraps return f(self, args, kwargs) File "/app/superset/dashboards/api.py", line 1408, in import_ command.run() File "/app/superset/commands/dashboard/importers/dispatcher.py", line 57, in run command.run() File "/app/superset/utils/decorators.py", line 266, in wrapped return on_error(ex) File "/app/superset/utils/decorators.py", line 236, in on_error raise ex File "/app/superset/utils/decorators.py", line 259, in wrapped result = func(args, **kwargs) File "/app/superset/commands/importers/v1/init.py", line 80, in run raise self.import_error() from ex superset.commands.dashboard.exceptions.DashboardImportError: Import dashboard failed for an unknown reason`


GET api/v1/dashboard/5/datasets

returns

`{"message":"Fatal error"}

2025-07-23 21:49:23,567:ERROR:flask_appbuilder.api:'str' object has no attribute 'get' Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/flask_appbuilder/api/init.py", line 111, in wraps return f(self, args, kwargs) File "/app/superset/views/base_api.py", line 119, in wraps duration, response = time_function(f, self, args, kwargs) File "/app/superset/utils/core.py", line 1364, in time_function response = func(*args, kwargs) File "/app/superset/utils/log.py", line 303, in wrapper value = f(args, *kwargs) File "/app/superset/dashboards/api.py", line 420, in get_datasets datasets = DashboardDAO.get_datasets_for_dashboard(id_or_slug) File "/app/superset/daos/dashboard.py", line 81, in get_datasets_for_dashboard return dashboard.datasets_trimmed_for_slices() File "/app/superset/models/dashboard.py", line 283, in datasets_trimmed_for_slices result.append(datasource.data_for_slices(slices)) File "/app/superset/connectors/sqla/models.py", line 446, in data_for_slices query_context = slc.get_query_context() File "/app/superset/models/slice.py", line 289, in get_query_context return self.get_query_context_factory().create( File "/app/superset/common/query_context_factory.py", line 63, in create if form_data and form_data.get("slice_id") is not None: AttributeError: 'str' object has no attribute 'get'`

Checklist

  • [x] I have searched Superset docs and Slack and didn't find a solution to my problem.
  • [x] I have searched the GitHub issue tracker and didn't find a similar bug report.
  • [x] I have checked Superset's logs for errors and if I found a relevant Python stacktrace, I included it here as text in the "additional context" section.

Comment From: dosubot[bot]

Hi @alexray92! I'm Dosu and I’m helping the superset team.

This error is caused by a bug in the import logic: during dashboard import, the code assigns a JSON string to query_context['form_data'] when it should be a dictionary. This breaks downstream code that expects a dict, leading to the TypeError and AttributeError you see (source). This is a known behavior in Superset's import/export flow—charts may lack a valid query context after import, which can trigger errors and warnings, even if charts and filters appear to work (source).

The recommended workaround is to manually open and save each chart in the UI after import. This regenerates the query context as a dictionary and resolves the error. If you have many charts, you can automate this with browser automation tools like Cypress (source). There is no built-in Superset command or API to bulk-repair these query contexts.

Recent pull requests show ongoing work to handle data type mismatches during import/export, but this specific issue with form_data as a string is not fully resolved in 4.1.x (source). For future imports, always ensure you export all related components (databases, datasets, charts, dashboards) and, after import, open and save each chart to avoid this problem (source).

If you want to patch the import logic to fix this at the code level, let me know and I can point you to the relevant code paths.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Chat with Dosu Join Discord Share on X