From 26ed0dca5e40e4ef0eeb1fa9d284a1238392fd41 Mon Sep 17 00:00:00 2001 From: "opensearch-trigger-bot[bot]" <98922864+opensearch-trigger-bot[bot]@users.noreply.github.com> Date: Tue, 31 Oct 2023 15:34:57 -0700 Subject: [PATCH] Fix error handling for user w/o proper permissions (#195) (#197) * fix error handling for user w/o indices access * update snapshots --------- (cherry picked from commit 03b18247989c9243e3e0c932a752c9f0e50801a2) Signed-off-by: Shenoy Pratik Signed-off-by: github-actions[bot] Co-authored-by: github-actions[bot] --- public/components/Main/__snapshots__/main.test.tsx.snap | 2 +- public/components/SQLPage/table_view.tsx | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/public/components/Main/__snapshots__/main.test.tsx.snap b/public/components/Main/__snapshots__/main.test.tsx.snap index 1735ccb1..63d0698f 100644 --- a/public/components/Main/__snapshots__/main.test.tsx.snap +++ b/public/components/Main/__snapshots__/main.test.tsx.snap @@ -2381,7 +2381,7 @@ exports[`
spec click run button, and response causes an error 1`] = ` class="euiText euiText--medium" >

- err + Error in loading OpenSearch indices

diff --git a/public/components/SQLPage/table_view.tsx b/public/components/SQLPage/table_view.tsx index cbe9987c..9ff070b7 100644 --- a/public/components/SQLPage/table_view.tsx +++ b/public/components/SQLPage/table_view.tsx @@ -112,7 +112,7 @@ export const TableView = ({ http, selectedItems, updateSQLQueries, refreshTree } body: JSON.stringify(query), }) .then((res) => { - const responseObj = res.data.resp ? JSON.parse(res.data.resp) : {}; + const responseObj = JSON.parse(res.data.resp); const dataRows: any[][] = _.get(responseObj, 'datarows'); if (dataRows.length > 0) { const fields = dataRows.map((data) => { @@ -131,9 +131,9 @@ export const TableView = ({ http, selectedItems, updateSQLQueries, refreshTree } console.error(err); setIsLoading({ flag: false, - status: err, + status: 'Error in loading OpenSearch indices', }); - setToast(`ERROR ${err}`, 'danger'); + setToast(`Error in loading OpenSearch indices, please check user permissions`, 'danger'); }); } else { setTableNames([]); @@ -536,7 +536,7 @@ export const TableView = ({ http, selectedItems, updateSQLQueries, refreshTree } {node.type === TREE_ITEM_TABLE_NAME_DEFAULT_NAME && !node.isLoading && ( handleQuery(e,parentName,node.name)} + onClick={(e) => handleQuery(e, parentName, node.name)} > )}