From e7821f2e751f1793f95bac5ae3e5ec2d0a6327f8 Mon Sep 17 00:00:00 2001 From: Yannick1712 <52333989+Yannick1712@users.noreply.github.com> Date: Thu, 29 Jan 2026 13:59:23 +0100 Subject: [PATCH 1/2] [DEV-4545] dfxApproval kyc bug --- .../generic/kyc/services/kyc.service.ts | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/subdomains/generic/kyc/services/kyc.service.ts b/src/subdomains/generic/kyc/services/kyc.service.ts index d98549825a..e0efeaebef 100644 --- a/src/subdomains/generic/kyc/services/kyc.service.ts +++ b/src/subdomains/generic/kyc/services/kyc.service.ts @@ -391,8 +391,21 @@ export class KycService { if (approvalStep?.isOnHold) { await this.kycStepRepo.update(...approvalStep.manualReview()); } else if (!approvalStep) { - const newStep = await this.initiateStep(kycStep.userData, KycStepName.DFX_APPROVAL); - await this.kycStepRepo.update(...newStep.manualReview()); + try { + const newStep = await this.initiateStep(kycStep.userData, KycStepName.DFX_APPROVAL); + await this.kycStepRepo.update(...newStep.manualReview()); + } catch (e) { + if (e.message.includes('Cannot insert duplicate key')) { + const dfxApprovalStep = await this.kycStepRepo.findOneBy({ + name: KycStepName.DFX_APPROVAL, + status: ReviewStatus.ON_HOLD, + userData: { id: kycStep.userData.id }, + }); + await this.kycStepRepo.update(...dfxApprovalStep.manualReview()); + } else { + throw e; + } + } } } } From ab14e49d879197f82493b22e86577f33bd9bdaf1 Mon Sep 17 00:00:00 2001 From: Yannick1712 <52333989+Yannick1712@users.noreply.github.com> Date: Fri, 30 Jan 2026 00:05:02 +0100 Subject: [PATCH 2/2] [DEV-4545] Refactoring --- .../generic/kyc/services/kyc.service.ts | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/subdomains/generic/kyc/services/kyc.service.ts b/src/subdomains/generic/kyc/services/kyc.service.ts index e0efeaebef..2290bb2c05 100644 --- a/src/subdomains/generic/kyc/services/kyc.service.ts +++ b/src/subdomains/generic/kyc/services/kyc.service.ts @@ -391,21 +391,18 @@ export class KycService { if (approvalStep?.isOnHold) { await this.kycStepRepo.update(...approvalStep.manualReview()); } else if (!approvalStep) { - try { - const newStep = await this.initiateStep(kycStep.userData, KycStepName.DFX_APPROVAL); - await this.kycStepRepo.update(...newStep.manualReview()); - } catch (e) { - if (e.message.includes('Cannot insert duplicate key')) { - const dfxApprovalStep = await this.kycStepRepo.findOneBy({ + const newStep = await this.initiateStep(kycStep.userData, KycStepName.DFX_APPROVAL).catch((e) => { + if (e.message.includes('Cannot insert duplicate key')) + return this.kycStepRepo.findOneBy({ name: KycStepName.DFX_APPROVAL, status: ReviewStatus.ON_HOLD, userData: { id: kycStep.userData.id }, }); - await this.kycStepRepo.update(...dfxApprovalStep.manualReview()); - } else { - throw e; - } - } + + throw e; + }); + + if (newStep) await this.kycStepRepo.update(...newStep.manualReview()); } } }