dosubot[bot] commented on issue #41245: URL: https://github.com/apache/superset/issues/41245#issuecomment-4751539980
<!-- Answer --> I can confirm this bug and the root cause analysis is spot-on, though the exact mechanism is slightly different from what's described in the issue. **The actual flow:** 1. SQL Lab bootstraps via `GET /api/v1/sqllab/` which calls `DatabaseDAO.find_all()` — this fetches **all** databases without pagination [[1]](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/sqllab/utils.py) [[2]](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/daos/base.py). So the initial Redux state is complete. 2. Then `SqlEditorLeftBar` mounts and renders the `DatabaseSelector` component, which calls `loadDatabases` **with pagination** (`page` and `page_size` parameters) [[3]](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset-frontend/src/components/DatabaseSelector/index.tsx). 3. The paginated result (default ~20 databases) is passed to the `handleDbList` callback, which dispatches `SET_DATABASES` [[4]](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset-frontend/src/SqlLab/components/SqlEditorLeftBar/index.tsx#L193-L198). 4. The `SET_DATABASES` reducer **completely replaces** the `databases` state rather than merging with the existing bootstrap data [[5]](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset-frontend/src/SqlLab/reducers/sqlLab.js#L667-L676): ```javascript [actions.SET_DATABASES]() { const databases = {}; action.databases.forEach(db => { databases[db.id] = { ...db, extra_json: JSON.parse(db.extra || '') }; }); return { ...state, databases }; // full replacement, not merge }, ``` 5. All databases from the bootstrap that weren't in the paginated response are now gone from Redux → the "database not found" warning fires [[6]](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset-frontend/src/SqlLab/components/SqlEditor/index.tsx#L321-L324). **The fix should target the overwrite, not the fetch.** A few approaches: - **Change `SET_DATABASES` to merge** instead of replace: `return { ...state, databases: { ...state.databases, ...databases } }` - **Remove the `getDbList` dispatch** from `SqlEditorLeftBar` since the bootstrap already provides the complete list, and let `DatabaseSelector` manage its own local state for the dropdown - **Pass a large `page_size`** in the `loadDatabases` call (your Option A), though this only masks the real issue Your `FLASK_APP_MUTATOR` workaround is valid for now but won't prevent the overwrite — it works because it changes the default page size for all endpoints, which happens to affect the `DatabaseSelector` fetch too. The cleanest short-term fix would be changing the reducer to merge. <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=reply-with-mention&utm_term=apache%2Fsuperset).* --- Docs are dead. Just use [Dosu](https://dosu.dev?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=static-docs-tagline&utm_term=apache%2Fsuperset). [](https://app.dosu.dev/response-feedback?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=static-docs-feedback&utm_term=apache%2Fsuperset&message_id=31648160-3312-4aab-9b58-9447103066ef) [](https://github.dosu.com/apache/superset?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=static-docs-ask-repo&utm_term=apache%2Fsuperset) [](https://app.dosu.dev/signup?referrer=openSource&source=github-footer&utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=static-docs-share-team&utm_term=apache%2Fsuperset) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
