From b6bc83af6c165de9eb8a45f7618f73607a7d873b Mon Sep 17 00:00:00 2001 From: parthy007 Date: Mon, 7 Jul 2025 17:01:54 +0530 Subject: [PATCH] Delete workspace_constant when not required --- server/src/modules/data-sources/util.service.ts | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/server/src/modules/data-sources/util.service.ts b/server/src/modules/data-sources/util.service.ts index 041a4817e3..77c251b352 100644 --- a/server/src/modules/data-sources/util.service.ts +++ b/server/src/modules/data-sources/util.service.ts @@ -280,16 +280,26 @@ export class DataSourcesUtilService implements IDataSourcesUtilService { const credentialValue = option['value']; if (option['encrypted']) { + const existingCredentialId = + dataSource?.options && dataSource.options[key] && dataSource.options[key]['credential_id']; + if (credentialValue && (credentialValue.includes('{{constants') || credentialValue.includes('{{secrets'))) { if (!parsedOptions[key]) { parsedOptions[key] = {}; } parsedOptions[key].workspace_constant = credentialValue; + } else { + if ( + existingCredentialId && + credentialValue !== undefined && + credentialValue !== (await this.credentialService.getValue(existingCredentialId)) + ) { + if (parsedOptions[key]) { + delete parsedOptions[key].workspace_constant; + } + } } - const existingCredentialId = - dataSource?.options && dataSource.options[key] && dataSource.options[key]['credential_id']; - if (existingCredentialId) { if (credentialValue !== undefined) { await this.credentialService.update(existingCredentialId, credentialValue || '');