From 2e4fc1168a0688cb03fcbf92e1e561ecb3cfb87c Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Wed, 8 Feb 2023 19:17:15 +0000 Subject: [PATCH] Minor fix for the plugin datasource error that occurred when opening apps in an environment where the datasource no longer exists. --- packages/server/src/api/controllers/datasource.ts | 1 - packages/server/src/sdk/app/datasources/datasources.ts | 7 ++++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/server/src/api/controllers/datasource.ts b/packages/server/src/api/controllers/datasource.ts index 469cd29b56..d212f7f361 100644 --- a/packages/server/src/api/controllers/datasource.ts +++ b/packages/server/src/api/controllers/datasource.ts @@ -14,7 +14,6 @@ import { invalidateDynamicVariables } from "../../threads/utils" import { db as dbCore, context, events } from "@budibase/backend-core" import { UserCtx, Datasource, Row } from "@budibase/types" import sdk from "../../sdk" -import { mergeConfigs } from "../../sdk/app/datasources/datasources" export async function fetch(ctx: UserCtx) { // Get internal tables diff --git a/packages/server/src/sdk/app/datasources/datasources.ts b/packages/server/src/sdk/app/datasources/datasources.ts index dfcde96cfc..804eb1366b 100644 --- a/packages/server/src/sdk/app/datasources/datasources.ts +++ b/packages/server/src/sdk/app/datasources/datasources.ts @@ -63,8 +63,12 @@ function useEnvVars(str: any) { export async function removeSecrets(datasources: Datasource[]) { const definitions = await getDefinitions() + const finalDatasources = [] for (let datasource of datasources) { const schema = definitions[datasource.source] + if (!schema) { + continue + } if (datasource.config) { // strip secrets from response, so they don't show in the network request if (datasource.config.auth) { @@ -93,8 +97,9 @@ export async function removeSecrets(datasources: Datasource[]) { } } } + finalDatasources.push(datasource) } - return datasources + return finalDatasources } export async function removeSecretSingle(datasource: Datasource) {