Skip to content

[Bug] [Backend] Purge Orphan KYC Documents from Cloudinary Upon Account Deletion #720

Description

@Pee-pheelips

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

  1. Before deleting the KYCDocument records in the database transaction, query the document URLs and public_ids.
  2. In the controller or deletion service, call deleteFromCloudinary(public_id) for each file.
  3. Ensure that if the Cloudinary deletion fails, it logs an alert so developers can manually reconcile or retry the deletion.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Stellar WaveIssues in the Stellar wave program

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions