diff --git a/packages/server/src/api/controllers/datasource.ts b/packages/server/src/api/controllers/datasource.ts index e6866d528c..363cde2e6f 100644 --- a/packages/server/src/api/controllers/datasource.ts +++ b/packages/server/src/api/controllers/datasource.ts @@ -128,12 +128,20 @@ export async function verify( ) { const datasource = ctx.request.body.datasource const connector = (await getConnector(datasource)) as IntegrationBase - if (!connector.connection) { + if (!connector.testConnection) { ctx.throw(400, "Connection information verification not supported") } - const connectionInfo = await connector.connection() - ctx.body = { - connected: connectionInfo.connected, + const response = await connector.testConnection() + + if (typeof response === "boolean") { + ctx.body = { + connected: response, + } + } else { + ctx.body = { + connected: false, + error: response.error + } } } diff --git a/packages/types/src/api/web/app/datasource.ts b/packages/types/src/api/web/app/datasource.ts index 36e081d9f6..983fd45b92 100644 --- a/packages/types/src/api/web/app/datasource.ts +++ b/packages/types/src/api/web/app/datasource.ts @@ -20,6 +20,7 @@ export interface VerifyDatasourceRequest { export interface VerifyDatasourceResponse { connected: boolean + error?: string } export interface UpdateDatasourceRequest extends Datasource {