From 50a76e6b276a4f08e41f0e600bc8265d01e3db69 Mon Sep 17 00:00:00 2001 From: Morgan <33722304+ThyMinimalDev@users.noreply.github.com> Date: Fri, 14 Mar 2025 08:13:41 +0200 Subject: [PATCH] fix: delegation credential not found (#20055) --- ...anizations-delegation-credential.service.ts | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/apps/api/v2/src/modules/organizations/delegation-credentials/services/organizations-delegation-credential.service.ts b/apps/api/v2/src/modules/organizations/delegation-credentials/services/organizations-delegation-credential.service.ts index 1f39ef937d..b42d63e0f9 100644 --- a/apps/api/v2/src/modules/organizations/delegation-credentials/services/organizations-delegation-credential.service.ts +++ b/apps/api/v2/src/modules/organizations/delegation-credentials/services/organizations-delegation-credential.service.ts @@ -38,6 +38,15 @@ export class OrganizationsDelegationCredentialService { delegatedServiceAccountUser: User, body: UpdateDelegationCredentialInput ) { + const delegationCredential = + await this.organizationsDelegationCredentialRepository.findByIdWithWorkspacePlatform( + delegationCredentialId + ); + + if (!delegationCredential) { + throw new NotFoundException(`DelegationCredential with id ${delegationCredentialId} not found`); + } + if (body.enabled !== undefined) { await this.updateDelegationCredentialEnabled( orgId, @@ -49,15 +58,8 @@ export class OrganizationsDelegationCredentialService { if (body.serviceAccountKey !== undefined) { await this.updateDelegationCredentialServiceAccountKey(delegationCredentialId, body.serviceAccountKey); } - const delegationCredential = - await this.organizationsDelegationCredentialRepository.findByIdWithWorkspacePlatform( - delegationCredentialId - ); - if (!delegationCredential) { - throw new NotFoundException(`DelegationCredential with id ${delegationCredentialId} not found`); - } - return delegationCredential; + return { ...delegationCredential, enabled: body?.enabled ?? delegationCredential?.enabled }; } async updateDelegationCredentialEnabled(