You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by ri...@apache.org on 2026/06/02 15:52:10 UTC
(superset) branch master updated: fix(sql-lab): prevent crash when host shell lacks useAppDispatch export (#40591)
This is an automated email from the ASF dual-hosted git repository.
richardfogaca pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git
The following commit(s) were added to refs/heads/master by this push:
new 88abd41c8b8 fix(sql-lab): prevent crash when host shell lacks useAppDispatch export (#40591)
88abd41c8b8 is described below
commit 88abd41c8b83d79491ef2b7db4676df5bf43c3ca
Author: Richard Fogaca Nienkotter <63...@users.noreply.github.com>
AuthorDate: Tue Jun 2 12:52:01 2026 -0300
fix(sql-lab): prevent crash when host shell lacks useAppDispatch export (#40591)
Co-authored-by: yousoph <so...@gmail.com>
Co-authored-by: Claude Sonnet 4.6 <no...@anthropic.com>
---
.../src/SqlLab/components/EditorAutoSync/index.tsx | 2 +-
.../src/SqlLab/components/EditorWrapper/index.tsx | 2 +-
.../SqlLab/components/EditorWrapper/useKeywords.ts | 2 +-
.../components/ExploreCtasResultsButton/index.tsx | 2 +-
.../src/SqlLab/components/PopEditorTab/index.tsx | 2 +-
.../SqlLab/components/QueryAutoRefresh/index.tsx | 2 +-
.../SqlLab/components/QueryLimitSelect/index.tsx | 2 +-
.../src/SqlLab/components/QueryTable/index.tsx | 2 +-
.../src/SqlLab/components/ResultSet/index.tsx | 2 +-
.../SqlLab/components/SaveDatasetModal/index.tsx | 3 ++-
.../src/SqlLab/components/SouthPane/index.tsx | 2 +-
.../src/SqlLab/components/SqlEditor/index.tsx | 2 +-
.../SqlLab/components/SqlEditorLeftBar/index.tsx | 2 +-
.../SqlLab/components/SqlEditorTabHeader/index.tsx | 2 +-
.../SqlEditorTopBar/useDatabaseSelector.ts | 2 +-
.../src/SqlLab/components/TableElement/index.tsx | 2 +-
.../SqlLab/components/TableExploreTree/index.tsx | 2 +-
.../components/TableExploreTree/useTreeData.ts | 2 +-
.../src/SqlLab/components/TablePreview/index.tsx | 2 +-
.../src/SqlLab/hooks/useAppDispatch.ts | 28 ++++++++++++++++++++++
.../src/SqlLab/hooks/useAppSelector.ts | 24 +++++++++++++++++++
21 files changed, 72 insertions(+), 19 deletions(-)
diff --git a/superset-frontend/src/SqlLab/components/EditorAutoSync/index.tsx b/superset-frontend/src/SqlLab/components/EditorAutoSync/index.tsx
index a0e1da1d7d0..27ae3c8c9b6 100644
--- a/superset-frontend/src/SqlLab/components/EditorAutoSync/index.tsx
+++ b/superset-frontend/src/SqlLab/components/EditorAutoSync/index.tsx
@@ -20,7 +20,7 @@
import { useRef, useEffect, FC, useMemo } from 'react';
import { useSelector } from 'react-redux';
-import { useAppDispatch } from 'src/views/store';
+import { useAppDispatch } from 'src/SqlLab/hooks/useAppDispatch';
import { logging } from '@apache-superset/core/utils';
import {
SqlLabRootState,
diff --git a/superset-frontend/src/SqlLab/components/EditorWrapper/index.tsx b/superset-frontend/src/SqlLab/components/EditorWrapper/index.tsx
index 3a28a534b54..007dc2f9ff2 100644
--- a/superset-frontend/src/SqlLab/components/EditorWrapper/index.tsx
+++ b/superset-frontend/src/SqlLab/components/EditorWrapper/index.tsx
@@ -18,7 +18,7 @@
*/
import { useState, useEffect, useRef, useCallback, useMemo } from 'react';
import { shallowEqual, useSelector } from 'react-redux';
-import { useAppDispatch } from 'src/views/store';
+import { useAppDispatch } from 'src/SqlLab/hooks/useAppDispatch';
import { usePrevious } from '@superset-ui/core';
import { css, useTheme } from '@apache-superset/core/theme';
import { Global } from '@emotion/react';
diff --git a/superset-frontend/src/SqlLab/components/EditorWrapper/useKeywords.ts b/superset-frontend/src/SqlLab/components/EditorWrapper/useKeywords.ts
index ee0bdcb5a9b..b79a39b2742 100644
--- a/superset-frontend/src/SqlLab/components/EditorWrapper/useKeywords.ts
+++ b/superset-frontend/src/SqlLab/components/EditorWrapper/useKeywords.ts
@@ -18,7 +18,7 @@
*/
import { useEffect, useMemo, useRef } from 'react';
import { useStore } from 'react-redux';
-import { useAppDispatch } from 'src/views/store';
+import { useAppDispatch } from 'src/SqlLab/hooks/useAppDispatch';
import { t } from '@apache-superset/core/translation';
import { getExtensionsRegistry } from '@superset-ui/core';
diff --git a/superset-frontend/src/SqlLab/components/ExploreCtasResultsButton/index.tsx b/superset-frontend/src/SqlLab/components/ExploreCtasResultsButton/index.tsx
index 4cb4bcc0718..92da32c4398 100644
--- a/superset-frontend/src/SqlLab/components/ExploreCtasResultsButton/index.tsx
+++ b/superset-frontend/src/SqlLab/components/ExploreCtasResultsButton/index.tsx
@@ -17,7 +17,7 @@
* under the License.
*/
import { useSelector } from 'react-redux';
-import { useAppDispatch } from 'src/views/store';
+import { useAppDispatch } from 'src/SqlLab/hooks/useAppDispatch';
import { t } from '@apache-superset/core/translation';
import { VizType } from '@superset-ui/core';
import {
diff --git a/superset-frontend/src/SqlLab/components/PopEditorTab/index.tsx b/superset-frontend/src/SqlLab/components/PopEditorTab/index.tsx
index 24fecab9470..c8b937db206 100644
--- a/superset-frontend/src/SqlLab/components/PopEditorTab/index.tsx
+++ b/superset-frontend/src/SqlLab/components/PopEditorTab/index.tsx
@@ -18,7 +18,7 @@
*/
import { useEffect, useState } from 'react';
import { useSelector } from 'react-redux';
-import { useAppDispatch } from 'src/views/store';
+import { useAppDispatch } from 'src/SqlLab/hooks/useAppDispatch';
import URI from 'urijs';
import { pick } from 'lodash';
import { useComponentDidUpdate } from '@superset-ui/core';
diff --git a/superset-frontend/src/SqlLab/components/QueryAutoRefresh/index.tsx b/superset-frontend/src/SqlLab/components/QueryAutoRefresh/index.tsx
index ac1777ea3fe..4203a544c37 100644
--- a/superset-frontend/src/SqlLab/components/QueryAutoRefresh/index.tsx
+++ b/superset-frontend/src/SqlLab/components/QueryAutoRefresh/index.tsx
@@ -18,7 +18,7 @@
*/
import { useRef } from 'react';
import { useSelector } from 'react-redux';
-import { useAppDispatch } from 'src/views/store';
+import { useAppDispatch } from 'src/SqlLab/hooks/useAppDispatch';
import { isObject } from 'lodash';
import rison from 'rison';
import {
diff --git a/superset-frontend/src/SqlLab/components/QueryLimitSelect/index.tsx b/superset-frontend/src/SqlLab/components/QueryLimitSelect/index.tsx
index 9812ff227e3..e4012a890d1 100644
--- a/superset-frontend/src/SqlLab/components/QueryLimitSelect/index.tsx
+++ b/superset-frontend/src/SqlLab/components/QueryLimitSelect/index.tsx
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-import { useAppDispatch } from 'src/views/store';
+import { useAppDispatch } from 'src/SqlLab/hooks/useAppDispatch';
import { t } from '@apache-superset/core/translation';
import { Dropdown, Button } from '@superset-ui/core/components';
import { Menu } from '@superset-ui/core/components/Menu';
diff --git a/superset-frontend/src/SqlLab/components/QueryTable/index.tsx b/superset-frontend/src/SqlLab/components/QueryTable/index.tsx
index 33c4342a5aa..18a3d73235b 100644
--- a/superset-frontend/src/SqlLab/components/QueryTable/index.tsx
+++ b/superset-frontend/src/SqlLab/components/QueryTable/index.tsx
@@ -31,7 +31,7 @@ import { t } from '@apache-superset/core/translation';
import { QueryResponse, QueryState } from '@superset-ui/core';
import { useTheme } from '@apache-superset/core/theme';
import { shallowEqual, useSelector } from 'react-redux';
-import { useAppDispatch } from 'src/views/store';
+import { useAppDispatch } from 'src/SqlLab/hooks/useAppDispatch';
import {
queryEditorSetSql,
diff --git a/superset-frontend/src/SqlLab/components/ResultSet/index.tsx b/superset-frontend/src/SqlLab/components/ResultSet/index.tsx
index 5637e3c940a..8b74c9d29ca 100644
--- a/superset-frontend/src/SqlLab/components/ResultSet/index.tsx
+++ b/superset-frontend/src/SqlLab/components/ResultSet/index.tsx
@@ -28,7 +28,7 @@ import {
import AutoSizer from 'react-virtualized-auto-sizer';
import { shallowEqual, useSelector } from 'react-redux';
-import { useAppDispatch } from 'src/views/store';
+import { useAppDispatch } from 'src/SqlLab/hooks/useAppDispatch';
import { useHistory } from 'react-router-dom';
import { pick } from 'lodash';
import {
diff --git a/superset-frontend/src/SqlLab/components/SaveDatasetModal/index.tsx b/superset-frontend/src/SqlLab/components/SaveDatasetModal/index.tsx
index 281a2edcae2..9037fd42996 100644
--- a/superset-frontend/src/SqlLab/components/SaveDatasetModal/index.tsx
+++ b/superset-frontend/src/SqlLab/components/SaveDatasetModal/index.tsx
@@ -43,7 +43,8 @@ import {
} from '@superset-ui/core';
import { styled } from '@apache-superset/core/theme';
import { extendedDayjs as dayjs } from '@superset-ui/core/utils/dates';
-import { useAppDispatch, useAppSelector } from 'src/views/store';
+import { useAppDispatch } from 'src/SqlLab/hooks/useAppDispatch';
+import { useAppSelector } from 'src/SqlLab/hooks/useAppSelector';
import rison from 'rison';
import { createDatasource } from 'src/SqlLab/actions/sqlLab';
import { addDangerToast } from 'src/components/MessageToasts/actions';
diff --git a/superset-frontend/src/SqlLab/components/SouthPane/index.tsx b/superset-frontend/src/SqlLab/components/SouthPane/index.tsx
index 8094527eeba..d7ce10a7d51 100644
--- a/superset-frontend/src/SqlLab/components/SouthPane/index.tsx
+++ b/superset-frontend/src/SqlLab/components/SouthPane/index.tsx
@@ -18,7 +18,7 @@
*/
import { createRef, useCallback, useMemo } from 'react';
import { shallowEqual, useSelector } from 'react-redux';
-import { useAppDispatch } from 'src/views/store';
+import { useAppDispatch } from 'src/SqlLab/hooks/useAppDispatch';
import { nanoid } from 'nanoid';
import Tabs from '@superset-ui/core/components/Tabs';
import { t } from '@apache-superset/core/translation';
diff --git a/superset-frontend/src/SqlLab/components/SqlEditor/index.tsx b/superset-frontend/src/SqlLab/components/SqlEditor/index.tsx
index 271f87538c7..c07c01223f5 100644
--- a/superset-frontend/src/SqlLab/components/SqlEditor/index.tsx
+++ b/superset-frontend/src/SqlLab/components/SqlEditor/index.tsx
@@ -31,7 +31,7 @@ import {
import type { editors } from '@apache-superset/core';
import useEffectEvent from 'src/hooks/useEffectEvent';
import { shallowEqual, useSelector } from 'react-redux';
-import { useAppDispatch } from 'src/views/store';
+import { useAppDispatch } from 'src/SqlLab/hooks/useAppDispatch';
import AutoSizer from 'react-virtualized-auto-sizer';
import { t } from '@apache-superset/core/translation';
import {
diff --git a/superset-frontend/src/SqlLab/components/SqlEditorLeftBar/index.tsx b/superset-frontend/src/SqlLab/components/SqlEditorLeftBar/index.tsx
index 7dfe60f289f..c788dc13d64 100644
--- a/superset-frontend/src/SqlLab/components/SqlEditorLeftBar/index.tsx
+++ b/superset-frontend/src/SqlLab/components/SqlEditorLeftBar/index.tsx
@@ -17,7 +17,7 @@
* under the License.
*/
import { useCallback, useState } from 'react';
-import { useAppDispatch } from 'src/views/store';
+import { useAppDispatch } from 'src/SqlLab/hooks/useAppDispatch';
import { resetState } from 'src/SqlLab/actions/sqlLab';
import {
diff --git a/superset-frontend/src/SqlLab/components/SqlEditorTabHeader/index.tsx b/superset-frontend/src/SqlLab/components/SqlEditorTabHeader/index.tsx
index 3f707d25957..dc7804d4c4a 100644
--- a/superset-frontend/src/SqlLab/components/SqlEditorTabHeader/index.tsx
+++ b/superset-frontend/src/SqlLab/components/SqlEditorTabHeader/index.tsx
@@ -20,7 +20,7 @@ import { useMemo, FC } from 'react';
import { bindActionCreators } from 'redux';
import { useSelector, shallowEqual } from 'react-redux';
-import { useAppDispatch } from 'src/views/store';
+import { useAppDispatch } from 'src/SqlLab/hooks/useAppDispatch';
import { MenuDotsDropdown } from '@superset-ui/core/components';
import { Menu, MenuItemType } from '@superset-ui/core/components/Menu';
import { t } from '@apache-superset/core/translation';
diff --git a/superset-frontend/src/SqlLab/components/SqlEditorTopBar/useDatabaseSelector.ts b/superset-frontend/src/SqlLab/components/SqlEditorTopBar/useDatabaseSelector.ts
index 83d444418e3..dccccae1372 100644
--- a/superset-frontend/src/SqlLab/components/SqlEditorTopBar/useDatabaseSelector.ts
+++ b/superset-frontend/src/SqlLab/components/SqlEditorTopBar/useDatabaseSelector.ts
@@ -18,7 +18,7 @@
*/
import { useEffect, useCallback, useMemo, useState } from 'react';
import { useSelector } from 'react-redux';
-import { useAppDispatch } from 'src/views/store';
+import { useAppDispatch } from 'src/SqlLab/hooks/useAppDispatch';
import { SqlLabRootState } from 'src/SqlLab/types';
import {
diff --git a/superset-frontend/src/SqlLab/components/TableElement/index.tsx b/superset-frontend/src/SqlLab/components/TableElement/index.tsx
index 8ca87460387..6f113a21226 100644
--- a/superset-frontend/src/SqlLab/components/TableElement/index.tsx
+++ b/superset-frontend/src/SqlLab/components/TableElement/index.tsx
@@ -18,7 +18,7 @@
*/
import { useState, useRef, useEffect } from 'react';
import { useSelector } from 'react-redux';
-import { useAppDispatch } from 'src/views/store';
+import { useAppDispatch } from 'src/SqlLab/hooks/useAppDispatch';
import type { QueryEditor, SqlLabRootState, Table } from 'src/SqlLab/types';
import {
ButtonGroup,
diff --git a/superset-frontend/src/SqlLab/components/TableExploreTree/index.tsx b/superset-frontend/src/SqlLab/components/TableExploreTree/index.tsx
index d6804771b7a..2e6530eed24 100644
--- a/superset-frontend/src/SqlLab/components/TableExploreTree/index.tsx
+++ b/superset-frontend/src/SqlLab/components/TableExploreTree/index.tsx
@@ -26,7 +26,7 @@ import {
useMemo,
} from 'react';
import { useSelector, shallowEqual } from 'react-redux';
-import { useAppDispatch } from 'src/views/store';
+import { useAppDispatch } from 'src/SqlLab/hooks/useAppDispatch';
import { styled, css, useTheme } from '@apache-superset/core/theme';
import { t } from '@apache-superset/core/translation';
import AutoSizer from 'react-virtualized-auto-sizer';
diff --git a/superset-frontend/src/SqlLab/components/TableExploreTree/useTreeData.ts b/superset-frontend/src/SqlLab/components/TableExploreTree/useTreeData.ts
index 239f1f19c1c..6dd01a5279c 100644
--- a/superset-frontend/src/SqlLab/components/TableExploreTree/useTreeData.ts
+++ b/superset-frontend/src/SqlLab/components/TableExploreTree/useTreeData.ts
@@ -17,7 +17,7 @@
* under the License.
*/
import { useMemo, useReducer, useCallback } from 'react';
-import { useAppDispatch } from 'src/views/store';
+import { useAppDispatch } from 'src/SqlLab/hooks/useAppDispatch';
import { t } from '@apache-superset/core/translation';
import {
Table,
diff --git a/superset-frontend/src/SqlLab/components/TablePreview/index.tsx b/superset-frontend/src/SqlLab/components/TablePreview/index.tsx
index 9e9b72c0c4c..bc53ab7f61e 100644
--- a/superset-frontend/src/SqlLab/components/TablePreview/index.tsx
+++ b/superset-frontend/src/SqlLab/components/TablePreview/index.tsx
@@ -18,7 +18,7 @@
*/
import { type FC, useCallback, useMemo, useRef, useState } from 'react';
import { shallowEqual, useSelector } from 'react-redux';
-import { useAppDispatch } from 'src/views/store';
+import { useAppDispatch } from 'src/SqlLab/hooks/useAppDispatch';
import { nanoid } from 'nanoid';
import { t } from '@apache-superset/core/translation';
import { ClientErrorObject, getExtensionsRegistry } from '@superset-ui/core';
diff --git a/superset-frontend/src/SqlLab/hooks/useAppDispatch.ts b/superset-frontend/src/SqlLab/hooks/useAppDispatch.ts
new file mode 100644
index 00000000000..d8fe7ed6bb0
--- /dev/null
+++ b/superset-frontend/src/SqlLab/hooks/useAppDispatch.ts
@@ -0,0 +1,28 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import { useDispatch } from 'react-redux';
+import type { AppDispatch } from 'src/views/store';
+
+// In Module Federation deployments where the host shell shares src/views/store
+// as a singleton, a version skew between the shell and the SQL Lab chunk can
+// leave useAppDispatch undefined at runtime even though TypeScript types it as
+// always-present. Keep this hook free of runtime imports from src/views/store:
+// store initialization imports SqlLab persistence helpers, so importing store
+// values here can create an app-startup circular dependency.
+export const useAppDispatch: () => AppDispatch = useDispatch;
diff --git a/superset-frontend/src/SqlLab/hooks/useAppSelector.ts b/superset-frontend/src/SqlLab/hooks/useAppSelector.ts
new file mode 100644
index 00000000000..1391215bfd3
--- /dev/null
+++ b/superset-frontend/src/SqlLab/hooks/useAppSelector.ts
@@ -0,0 +1,24 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import { useSelector, type TypedUseSelectorHook } from 'react-redux';
+import type { RootState } from 'src/views/store';
+
+// Keep this hook free of runtime imports from src/views/store for the same
+// Module Federation version-skew case handled by useAppDispatch.
+export const useAppSelector: TypedUseSelectorHook<RootState> = useSelector;