Skip to content

fix(sqllab): preserve database state on SET_DATABASES#41281

Open
GagandeepSingh20 wants to merge 6 commits into
apache:masterfrom
GagandeepSingh20:fix-sql-lab-database-state
Open

fix(sqllab): preserve database state on SET_DATABASES#41281
GagandeepSingh20 wants to merge 6 commits into
apache:masterfrom
GagandeepSingh20:fix-sql-lab-database-state

Conversation

@GagandeepSingh20

@GagandeepSingh20 GagandeepSingh20 commented Jun 22, 2026

Copy link
Copy Markdown

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

@dosubot dosubot Bot added the sqllab Namespace | Anything related to the SQL Lab label Jun 22, 2026
@bito-code-review

bito-code-review Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

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 evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

@netlify

netlify Bot commented Jun 22, 2026

Copy link
Copy Markdown

Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit 3d97ced
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6a4ad9e114311800084df142
😎 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.

Comment thread superset-frontend/src/SqlLab/reducers/sqlLab.test.ts Outdated
Comment thread superset-frontend/src/SqlLab/reducers/sqlLab.test.ts Outdated
@rusackas

Copy link
Copy Markdown
Member

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

@github-actions

github-actions Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

⚠️ 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.

@codecov

codecov Bot commented Jun 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 64.70%. Comparing base (7cdfe3f) to head (3d97ced).

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #41281   +/-   ##
=======================================
  Coverage   64.70%   64.70%           
=======================================
  Files        2686     2686           
  Lines      148625   148625           
  Branches    34298    34298           
=======================================
+ Hits        96164    96173    +9     
+ Misses      50696    50690    -6     
+ Partials     1765     1762    -3     
Flag Coverage Δ
javascript 69.57% <100.00%> (+<0.01%) ⬆️

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

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

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

@GagandeepSingh20

Copy link
Copy Markdown
Author

@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!

@rusackas

Copy link
Copy Markdown
Member

@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

Comment thread superset-frontend/src/SqlLab/reducers/sqlLab.test.ts Outdated
@GagandeepSingh20

Copy link
Copy Markdown
Author

@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.

Comment thread superset-frontend/src/SqlLab/reducers/sqlLab.test.ts Outdated
Comment thread superset-frontend/src/SqlLab/reducers/sqlLab.test.ts Outdated
@bito-code-review

bito-code-review Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

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 evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

@GagandeepSingh20

Copy link
Copy Markdown
Author

@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 GagandeepSingh20 force-pushed the fix-sql-lab-database-state branch from a7c6352 to b0c570b Compare July 2, 2026 18:42
Comment on lines +46 to +51
const state = {
...initialState,
databases: {
[existingDbId]: existingDb,
},
} as any;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggestion: Replace the any cast on the reducer state with a concrete state type (for example, a properly typed partial or test-specific state interface) to preserve type safety. [custom_rule]

Severity Level: Minor ⚠️

Why it matters? 🤔

The rule forbids new or changed TypeScript code from using any. This test setup explicitly casts the reducer state to any, so the violation is real and present in the final code.

Fix in Cursor Fix in VSCode Claude

(Use Cmd/Ctrl + Click for best experience)

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** superset-frontend/src/SqlLab/reducers/sqlLab.test.ts
**Line:** 46:51
**Comment:**
	*Custom Rule: Replace the `any` cast on the reducer state with a concrete state type (for example, a properly typed partial or test-specific state interface) to preserve type safety.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
👍 | 👎

@bito-code-review

bito-code-review Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

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 evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/M sqllab Namespace | Anything related to the SQL Lab

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants