Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(sqllab): null database with backend persistence #19548

Merged
merged 1 commit into from
Apr 6, 2022

Conversation

villebro
Copy link
Member

@villebro villebro commented Apr 6, 2022

SUMMARY

This PR fixes two problems in SQL Lab if the SQLLAB_BACKEND_PERSISTENCE feature flag is enabled (default as of 2.0):

  • When opening SQL Lab and a persisted tab is referencing a database that has been deleted, SQL Lab will fail with a 500 (see error below). This is due to self.database being None
  • when the above has been resolved, and the user switches to a tab referencing a missing database, a 404 is returned from the function names request, which in turn triggers an error toast. As this is an expected case, we avoid dispatching an error toast for 404s.

SCRENSHOTS

When accessing SQL Lab with SQLLAB_BACKEND_PERSISTENCE turned on and a referenced database being missing, the following happens:

{
   "errors":[
      {
         "message":"'NoneType' object has no attribute 'database_name'",
         "error_type":"GENERIC_BACKEND_ERROR",
         "level":"error",
         "extra":{
            "issue_codes":[
               {
                  "code":1011,
                  "message":"Issue 1011 - Superset encountered an unexpected error."
               }
            ]
         }
      }
   ]
}

After the above has been fixed and switching tabs into a tab where the database is missing, the following error toast is brought up:
image

TESTING INSTRUCTIONS

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

@codecov
Copy link

codecov bot commented Apr 6, 2022

Codecov Report

Merging #19548 (ca01e2e) into master (e1ef2ba) will decrease coverage by 12.70%.
The diff coverage is 0.00%.

❗ Current head ca01e2e differs from pull request most recent head 05fc099. Consider uploading reports for the commit 05fc099 to get more accurate results

@@             Coverage Diff             @@
##           master   #19548       +/-   ##
===========================================
- Coverage   66.59%   53.89%   -12.71%     
===========================================
  Files        1682     1682               
  Lines       64321    64321               
  Branches     6561     6561               
===========================================
- Hits        42837    34665     -8172     
- Misses      19783    27955     +8172     
  Partials     1701     1701               
Flag Coverage Δ
hive 52.71% <ø> (ø)
mysql ?
postgres ?
presto 52.56% <ø> (ø)
python 56.51% <ø> (-25.89%) ⬇️
sqlite ?
unit 47.21% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
superset-frontend/src/SqlLab/actions/sqlLab.js 60.73% <0.00%> (ø)
superset/models/sql_lab.py 84.41% <ø> (-7.15%) ⬇️
superset/utils/dashboard_import_export.py 0.00% <0.00%> (-100.00%) ⬇️
superset/key_value/commands/upsert.py 0.00% <0.00%> (-89.59%) ⬇️
superset/key_value/commands/update.py 0.00% <0.00%> (-89.37%) ⬇️
superset/key_value/commands/delete.py 0.00% <0.00%> (-85.30%) ⬇️
superset/key_value/commands/delete_expired.py 0.00% <0.00%> (-80.77%) ⬇️
superset/dashboards/commands/importers/v0.py 14.79% <0.00%> (-75.15%) ⬇️
superset/datasets/commands/importers/v0.py 24.82% <0.00%> (-68.80%) ⬇️
superset/databases/commands/test_connection.py 31.42% <0.00%> (-68.58%) ⬇️
... and 265 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e1ef2ba...05fc099. Read the comment docs.

Copy link
Member

@zhaoyongjie zhaoyongjie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks!

@villebro villebro merged commit 2d81c4c into apache:master Apr 6, 2022
@villebro villebro deleted the villebro/sqllab_database_null branch April 6, 2022 10:10
villebro added a commit that referenced this pull request Apr 8, 2022
philipher29 pushed a commit to ValtechMobility/superset that referenced this pull request Jun 9, 2022
@mistercrunch mistercrunch added 🍒 1.5.0 🍒 1.5.1 🍒 1.5.2 🍒 1.5.3 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 2.0.0 labels Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels lts-v1 preset-io size/S 🍒 1.5.0 🍒 1.5.1 🍒 1.5.2 🍒 1.5.3 🚢 2.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants