diff --git a/packages/nc-gui/components/workspace/integrations/forms/EditOrAddDatabase.vue b/packages/nc-gui/components/workspace/integrations/forms/EditOrAddDatabase.vue index bf48dee7f3..96248c4403 100644 --- a/packages/nc-gui/components/workspace/integrations/forms/EditOrAddDatabase.vue +++ b/packages/nc-gui/components/workspace/integrations/forms/EditOrAddDatabase.vue @@ -367,10 +367,10 @@ const testConnection = async (retry = 0, initialConfig = null) => { } } -async function handleConnectionError(e: any, retry: number, initialConfig: any): Promise { - const MAX_RETRIES = 3 +const MAX_CONNECTION_RETRIES = 3 - if (retry >= MAX_RETRIES) { +async function handleConnectionError(e: any, retry: number, initialConfig: any): Promise { + if (retry >= MAX_CONNECTION_RETRIES) { testSuccess.value = false testConnectionError.value = await extractSdkResponseErrorMsg(e) // reset the connection config to initial state diff --git a/packages/nc-gui/utils/baseCreateUtils.ts b/packages/nc-gui/utils/baseCreateUtils.ts index 7950ce1a5c..a8d16ebbeb 100644 --- a/packages/nc-gui/utils/baseCreateUtils.ts +++ b/packages/nc-gui/utils/baseCreateUtils.ts @@ -223,47 +223,47 @@ enum CertTypes { key = 'key', } -function generateConfigFix(e: any) { - const errorHandlers = [ - { - messages: ['unable to get local issuer certificate', 'self signed certificate in certificate chain'], - codes: ['UNABLE_TO_GET_ISSUER_CERT_LOCALLY', 'SELF_SIGNED_CERT_IN_CHAIN'], - action: { - connection: { - ssl: { - rejectUnauthorized: false, - }, +const errorHandlers = [ + { + messages: ['unable to get local issuer certificate', 'self signed certificate in certificate chain'], + codes: ['UNABLE_TO_GET_ISSUER_CERT_LOCALLY', 'SELF_SIGNED_CERT_IN_CHAIN'], + action: { + connection: { + ssl: { + rejectUnauthorized: false, }, }, }, - { - messages: ['SSL is required'], - codes: ['28000'], // PostgreSQL error code for invalid authorization specification - action: { - connection: { - ssl: true, - }, + }, + { + messages: ['SSL is required'], + codes: ['28000'], // PostgreSQL error code for invalid authorization specification + action: { + connection: { + ssl: true, }, }, - { - messages: ['the server does not support SSL connections'], - codes: ['08P01'], // PostgreSQL error code for protocol violation - action: { - connection: { - ssl: false, - }, + }, + { + messages: ['the server does not support SSL connections'], + codes: ['08P01'], // PostgreSQL error code for protocol violation + action: { + connection: { + ssl: false, }, }, - ] + }, +] +function generateConfigFix(e: any) { for (const handler of errorHandlers) { const errorMessage = e?.response?.data?.msg const errorCode = e?.response?.data?.sql_code - if (!errorMessage || !errorCode) return + if (!errorMessage && !errorCode) return - const messageMatches = handler.messages.some((msg) => errorMessage?.includes?.(msg)) - const codeMatches = handler.codes.includes(errorCode) + const messageMatches = errorMessage && handler.messages.some((msg) => errorMessage?.includes?.(msg)) + const codeMatches = errorCode && handler.codes.includes(errorCode) if (messageMatches || codeMatches) { return handler.action