superset icon indicating copy to clipboard operation
superset copied to clipboard

fix(sqllab): preserve database state on SET_DATABASES

Open GagandeepSingh20 opened this issue 5 months ago • 2 comments

SUMMARY

Fixes an issue where SQL Lab could lose previously loaded database entries when additional database pages were fetched.

The SET_DATABASES reducer currently replaces the entire databases map in Redux state with the latest API response. Since DatabaseSelector loads databases through paginated requests, loading another page can remove database entries that were already present in state.

This change updates the reducer to merge incoming database entries into the existing state instead of replacing the entire map. A regression test has also been added to verify that previously loaded databases are preserved when additional database results are received.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Not applicable (no UI changes).

TESTING INSTRUCTIONS

Run: npm run test -- src/SqlLab/reducers/sqlLab.test.ts Verify the reducer test suite passes. Verify the new regression test confirms that existing database entries remain available after dispatching SET_DATABASES with additional database results.

ADDITIONAL INFORMATION

  • [x] Has associated issue:#41245
  • [ ] 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

GagandeepSingh20 avatar Jun 22 '26 09:06 GagandeepSingh20

Code Review Agent Run #531c26

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: 07e403d..07e403d
    • superset-frontend/src/SqlLab/reducers/sqlLab.test.ts
    • superset-frontend/src/SqlLab/reducers/sqlLab.ts
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • Eslint (Linter) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

bito-code-review[bot] avatar Jun 22 '26 09:06 bito-code-review[bot]

Deploy Preview for superset-docs-preview ready!

Name Link
Latest commit b1f8ebefed361e958a726dc9bf33305b9e506e9f
Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6a594eb5a23a8c0008128fc5
Deploy Preview https://deploy-preview-41281--superset-docs-preview.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

netlify avatar Jun 22 '26 09:06 netlify

Approving the CI run 🤞 @betodealmeida might be best to take a look here.

rusackas avatar Jun 24 '26 17:06 rusackas

⚠️ Translation Regression Detected

A source change in this PR renamed or reworded strings, invalidating existing translations (they are now #, fuzzy) in ar, it, ko, pt. Please resolve the affected .po files before merging.

Note: intentionally deleting a translatable string is not a regression and is not flagged here — only translations invalidated by a renamed/reworded source string are.

Language Fuzzy before Fuzzy after New
ar 1130 1133 +3
it 1660 1662 +2
ko 1514 1516 +2
pt 1835 1837 +2

How to fix

1. Install dependencies (if not already set up):

pip install -r superset/translations/requirements.txt
sudo apt-get install gettext   # or: brew install gettext

2. Re-extract strings and sync .po files:

./scripts/translations/babel_update.sh

This rewrites superset/translations/messages.pot from the current source files and merges the changes into every .po file. Strings whose msgid changed will be marked #, fuzzy.

3. Resolve the fuzzy entries in the affected language files (ar, it, ko, pt):

grep -n '#, fuzzy' superset/translations/<lang>/LC_MESSAGES/messages.po

For each fuzzy entry, either rewrite the msgstr to match the new string and remove the #, fuzzy line, or clear the msgstr to "" if you cannot provide a translation.

4. Commit your changes to the .po files.

github-actions[bot] avatar Jun 24 '26 17:06 github-actions[bot]

Codecov Report

:white_check_mark: All modified and coverable lines are covered by tests. :white_check_mark: Project coverage is 65.08%. Comparing base (9e38c1d) to head (5226f5a). :warning: Report is 51 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #41281   +/-   ##
=======================================
  Coverage   65.08%   65.08%           
=======================================
  Files        2752     2752           
  Lines      154475   154475           
  Branches    35404    35404           
=======================================
+ Hits       100544   100546    +2     
+ Misses      52019    52017    -2     
  Partials     1912     1912           
Flag Coverage Δ
javascript 70.61% <100.00%> (+<0.01%) :arrow_up:

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

:umbrella: View full report in Codecov by Harness.
:loudspeaker: Have feedback on the report? Share it here.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

codecov[bot] avatar Jun 24 '26 17:06 codecov[bot]

@rusackas Hi! Just following up on this PR since it's been a few days.

I wanted to check if there's anything else I should address on my side, or if there are any remaining concerns about the proposed fix. I'm happy to make any changes if needed.

Thanks for taking a look!

GagandeepSingh20 avatar Jun 28 '26 17:06 GagandeepSingh20

@GagandeepSingh20 I think the approach looks OK... I'll take another review pass at it when CI is green, but right now, it needs a rebase to fix the flagged translation problem, and you'll need to get pre-commit to pass.

Superset uses Git pre-commit hooks courtesy of pre-commit. To install run the following:

pip3 install -r requirements/development.txt
pre-commit install

A series of checks will now run when you make a git commit.

Alternatively it is possible to run pre-commit by running pre-commit manually:

pre-commit run --all-files

rusackas avatar Jun 29 '26 00:06 rusackas

@sadpandajoe Thanks for the review! I flattened the regression test by removing the extra describe('Database actions') block and kept the test directly under the existing sqlLabReducer describe block.

I pushed the update to the PR branch, and CI should run again now.

GagandeepSingh20 avatar Jun 30 '26 07:06 GagandeepSingh20

Code Review Agent Run #2e511d

Actionable Suggestions - 0
Review Details
  • Files reviewed - 1 · Commit Range: 07e403d..75c80d2
    • superset-frontend/src/SqlLab/reducers/sqlLab.test.ts
  • Files skipped - 0
  • Tools
    • Eslint (Linter) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

bito-code-review[bot] avatar Jun 30 '26 10:06 bito-code-review[bot]

@sadpandajoe Thanks for the review and approval! I’ll wait for the workflows to be approved/run, and can update the branch if needed.

GagandeepSingh20 avatar Jul 01 '26 16:07 GagandeepSingh20

Code Review Agent Run #f0887c

Actionable Suggestions - 0
Review Details
  • Files reviewed - 1 · Commit Range: 75c80d2..ac835da
    • superset-frontend/src/SqlLab/reducers/sqlLab.test.ts
  • Files skipped - 0
  • Tools
    • Eslint (Linter) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

bito-code-review[bot] avatar Jul 05 '26 18:07 bito-code-review[bot]

I merged the latest master into this branch to keep the PR up to date. After that, the only remaining failing check appears to be:

Frontend Build CI / lint-frontend

@sadpandajoe Before making any unrelated changes, could you please advise whether this is something I should fix in this PR, or if the check needs to be rerun / handled separately?

Happy to make any required changes once confirmed.

GagandeepSingh20 avatar Jul 08 '26 14:07 GagandeepSingh20

Hey @sadpandajoe @betodealmeida, I've independently verified this fix works. Here's my video proof showing:

  1. 26 databases loaded (more than the default page_size of 20)
  2. (id=26, beyond first 20 results) works without any 'database not found' warning
  3. After hard reload, the tab loads cleanly with no yellow banner

Screencast from 2026-07-18 18-07-11.webm

LGTM, looking forward to this getting merged! 🙏

prathamesh04 avatar Jul 18 '26 12:07 prathamesh04

Code Review Agent Run #6c2ca5

Actionable Suggestions - 0
Review Details
  • Files reviewed - 1 · Commit Range: ac835da..5226f5a
    • superset-frontend/src/SqlLab/reducers/sqlLab.test.ts
  • Files skipped - 0
  • Tools
    • Eslint (Linter) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

bito-code-review[bot] avatar Jul 18 '26 16:07 bito-code-review[bot]