Bug description

Adding Google sheets to the DBS_AVAILABLE_DENYLIST in a config py ("gsheets": {"apsw"}) results in a KeyError: when views/base.py tries to verify the installation through the line frontend_config["HAS_GSHEETS_INSTALLED"] = bool(available_specs[GSheetsEngineSpec]).

Screenshots/recordings

No response

Superset version

master / latest-dev

Python version

3.9

Node version

18 or greater

Browser

Chrome

Additional context

20250321 13:51:01,967:WARNING:superset.views.error_handling:Exception

Traceback (most recent call last): File "/app/.venv/lib/python3.11/sitepackages/flask/app.py", line 1484, in full_dispatch_request rv = self.dispatch_request() ^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.11/sitepackages/flask/app.py", line 1469, in dispatch_request return self.ensure_sync(self.view_functions[rule.endpoint])(view_args) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.11/sitepackages/flask_appbuilder/security/decorators.py", line 151, in wraps return f(self, *args, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/superset/views/dashboard/views.py", line 60, in list return super().render_app_template() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/superset/views/base.py", line 371, in render_app_template "common": common_bootstrap_payload(), ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/superset/views/base.py", line 344, in common_bootstrap_payload cached_common_bootstrap_data(utils.get_user_id(), get_locale()), ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.11/sitepackages/flask_caching/init.py", line 899, in decorated_function rv = self._call_fn(f, *args, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.11/sitepackages/flask_caching/init.py", line 185, in _call_fn return ensure_sync(fn)(args, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/superset/views/base.py", line 321, in cached_common_bootstrap_data frontend_config["HAS_GSHEETS_INSTALLED"] = bool(available_specs[GSheetsEngineSpec]) ^^^^^^^^^^^^^^^^^^^ KeyError: 20250321 13:51:01,968:ERROR:superset.views.error_handling: Traceback (most recent call last): File "/app/.venv/lib/python3.11/sitepackages/flask/app.py", line 1484, in full_dispatch_request rv = self.dispatch_request() ^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.11/sitepackages/flask/app.py", line 1469, in dispatch_request return self.ensure_sync(self.view_functions[rule.endpoint])(view_args) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.11/sitepackages/flask_appbuilder/security/decorators.py", line 151, in wraps return f(self, args, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/superset/views/dashboard/views.py", line 60, in list return super().render_app_template() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/superset/views/base.py", line 371, in render_app_template "common": common_bootstrap_payload(), ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/superset/views/base.py", line 344, in common_bootstrap_payload cached_common_bootstrap_data(utils.get_user_id(), get_locale()), ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.11/sitepackages/flask_caching/init.py", line 899, in decorated_function rv = self._call_fn(f, args, *kwargs)

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]

The issue you're encountering is due to the GSheetsEngineSpec being added to the DBS_AVAILABLE_DENYLIST, which results in it being removed from the available_specs. Consequently, when the code tries to access available_specs[GSheetsEngineSpec] to set the HAS_GSHEETS_INSTALLED key in the frontend_config, it raises a KeyError because GSheetsEngineSpec is no longer present in available_specs.

To resolve this issue, you can modify the code to check if GSheetsEngineSpec is in available_specs before attempting to access it. Here's a potential solution:

frontend_config["HAS_GSHEETS_INSTALLED"] = GSheetsEngineSpec in available_specs and bool(available_specs[GSheetsEngineSpec])

This change ensures that the code only attempts to access available_specs[GSheetsEngineSpec] if GSheetsEngineSpec is indeed present in available_specs, thus preventing the KeyError.

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

Comment From: chrisvnimbus

Yeah, that's what I figured. Created a pull request for the fix.

Comment From: rusackas

Thanks for the PR!