From 2e47cd3628f75fb5a6a1a1a8fc955b4c6b9fe091 Mon Sep 17 00:00:00 2001 From: Alik Rakhmonov Date: Tue, 3 Dec 2024 12:02:28 +0100 Subject: [PATCH 1/2] HCK-8840: RE BigQuery Instance - Display error if dataset is not found --- reverse_engineering/api.js | 6 ++++++ .../connectionSettingsModalConfig.json | 6 +++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/reverse_engineering/api.js b/reverse_engineering/api.js index e0b7157..9a5ef2b 100644 --- a/reverse_engineering/api.js +++ b/reverse_engineering/api.js @@ -51,6 +51,11 @@ const testConnection = async (connectionInfo, logger, cb) => { const bigQueryHelper = createBigQueryHelper(client, log); await bigQueryHelper.getDatasets(); + const datasetName = connectionInfo.datasetId || connectionInfo.data?.databaseName; + if (datasetName) { + await bigQueryHelper.getTables(datasetName); + } + cb(); } catch (err) { cb(prepareError(logger, err)); @@ -456,6 +461,7 @@ const getPartitioningRange = rangePartitioning => { const prepareError = (logger, error) => { const err = { + code: error.code, message: error.message, stack: error.stack, }; diff --git a/reverse_engineering/connection_settings_modal/connectionSettingsModalConfig.json b/reverse_engineering/connection_settings_modal/connectionSettingsModalConfig.json index 5c66a4b..637da4a 100644 --- a/reverse_engineering/connection_settings_modal/connectionSettingsModalConfig.json +++ b/reverse_engineering/connection_settings_modal/connectionSettingsModalConfig.json @@ -15,18 +15,18 @@ "options": [{ "value": "", "label": "Google Cloud" }] }, { - "inputLabel": "Project id", + "inputLabel": "Project ID", "inputKeyword": "projectId", "inputType": "text", "inputPlaceholder": "Optional", "inputTooltip": "Project ID on Google Cloud Platform" }, { - "inputLabel": "Dataset id", + "inputLabel": "Dataset name", "inputKeyword": "datasetId", "inputType": "text", "inputPlaceholder": "Optional", - "inputTooltip": "Dataset ID on Google Cloud Platform" + "inputTooltip": "Dataset name on Google Cloud Platform" }, { "inputLabel": "Key file", From d0e93dde1dbd1ec2f6dd4e87b536e0d3948f638e Mon Sep 17 00:00:00 2001 From: Alik Rakhmonov Date: Thu, 5 Dec 2024 09:40:11 +0100 Subject: [PATCH 2/2] fix --- localization/en.json | 3 ++- reverse_engineering/api.js | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/localization/en.json b/localization/en.json index 8b7caed..99b80eb 100644 --- a/localization/en.json +++ b/localization/en.json @@ -154,5 +154,6 @@ "MODAL_WINDOW___DB_CONNECTIONS_LIST_TITLE": "BigQuery Connections", "MAIN_MENU___FORWARD_DB_BUCKETS": "BigQuery DDL...", "MODAL_WINDOW___FE_SCRIPT_OPTION_CREATE": "Create", - "MODAL_WINDOW___FE_SCRIPT_OPTION_UPDATE": "Alter" + "MODAL_WINDOW___FE_SCRIPT_OPTION_UPDATE": "Alter", + "PROJECT_DATASET_NOT_FOUND": "The project or dataset could not be located in the BigQuery instance.\nDouble-check the project id and dataset name. Ensure the necessary permissions are in place to access the project or dataset.\nFor further assistance, please refer to the online documentation." } diff --git a/reverse_engineering/api.js b/reverse_engineering/api.js index 9a5ef2b..29fb4cc 100644 --- a/reverse_engineering/api.js +++ b/reverse_engineering/api.js @@ -58,6 +58,9 @@ const testConnection = async (connectionInfo, logger, cb) => { cb(); } catch (err) { + if (err.code === 404) { + err.customMsgCode = 'PROJECT_DATASET_NOT_FOUND'; + } cb(prepareError(logger, err)); } }; @@ -97,6 +100,9 @@ const getDbCollectionsNames = async (connectionInfo, logger, cb, app) => { cb(null, tablesByDataset); } catch (err) { + if (err.code === 404) { + err.customMsgCode = 'PROJECT_DATASET_NOT_FOUND'; + } cb(prepareError(logger, err)); } }; @@ -464,6 +470,7 @@ const prepareError = (logger, error) => { code: error.code, message: error.message, stack: error.stack, + customMsgCode: error.customMsgCode, }; logger.log('error', err, 'Reverse Engineering error');