fix: delegation credential not found (#20055)

This commit is contained in:
Morgan
2025-03-14 06:13:41 +00:00
committed by GitHub
parent be4d3170db
commit 50a76e6b27
@@ -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(