From b7db5d8fca8bf0312dd1efe096471693cfec4233 Mon Sep 17 00:00:00 2001 From: Hetu Nandu Date: Wed, 14 Feb 2024 14:22:04 +0530 Subject: [PATCH] fix: Datasource null check in QueryDebugger (#31115) Adds null check for datasources as sometimes they may not be available ## Summary by CodeRabbit - **Bug Fixes** - Improved reliability in accessing datasource properties within the Query Debugger, ensuring safer operations and correcting the datasource structure fetching process. --- .../pages/Editor/QueryEditor/QueryDebuggerTabs.tsx | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/app/client/src/pages/Editor/QueryEditor/QueryDebuggerTabs.tsx b/app/client/src/pages/Editor/QueryEditor/QueryDebuggerTabs.tsx index 532c6cf8d0..ea82cda35a 100644 --- a/app/client/src/pages/Editor/QueryEditor/QueryDebuggerTabs.tsx +++ b/app/client/src/pages/Editor/QueryEditor/QueryDebuggerTabs.tsx @@ -98,18 +98,21 @@ function QueryDebuggerTabs({ ); const datasourceStructure = useSelector((state) => - getDatasourceStructureById(state, currentActionConfig?.datasource.id || ""), + getDatasourceStructureById( + state, + currentActionConfig?.datasource?.id ?? "", + ), ); useEffect(() => { if ( - currentActionConfig?.datasource.id && + currentActionConfig?.datasource?.id && datasourceStructure === undefined && pluginDatasourceForm !== DatasourceComponentTypes.RestAPIDatasourceForm ) { dispatch( fetchDatasourceStructure( - currentActionConfig?.datasource.id, + currentActionConfig.datasource.id, true, DatasourceStructureContext.QUERY_EDITOR, ), @@ -180,7 +183,7 @@ function QueryDebuggerTabs({ }); } - if (showSchema && currentActionConfig) { + if (showSchema && currentActionConfig && currentActionConfig.datasource) { responseTabs.unshift({ key: "schema", title: "Schema",