Description
When executing a merchant deletion request in merchantDeletion.service.ts, the database records for KYC documents are deleted:
// 3. Delete KYC documents (files already on Cloudinary — caller must purge separately)
await tx.kYCDocument.deleteMany({ where: { kyc: { merchantId } } });
However, the caller (merchantDeletion.controller.ts) never performs the file purge. This leaves sensitive merchant PII (passport files, proof of address) orphaned on Cloudinary indefinitely.
Steps to Resolve
- Before deleting the
KYCDocument records in the database transaction, query the document URLs and public_ids.
- In the controller or deletion service, call
deleteFromCloudinary(public_id) for each file.
- Ensure that if the Cloudinary deletion fails, it logs an alert so developers can manually reconcile or retry the deletion.
Description
When executing a merchant deletion request in
merchantDeletion.service.ts, the database records for KYC documents are deleted:However, the caller (
merchantDeletion.controller.ts) never performs the file purge. This leaves sensitive merchant PII (passport files, proof of address) orphaned on Cloudinary indefinitely.Steps to Resolve
KYCDocumentrecords in the database transaction, query the document URLs andpublic_ids.deleteFromCloudinary(public_id)for each file.