Already deleted error when cascade deleting in report
Description
When deleting a report choosing the cascade delete option, we sometimes get an Already deleted error. This is due to a bug in the cascade delete of the report: we try to delete all orphan elements concurrently, relations included. However, relations are sometimes already deleted when the report tries to delete them, because it was deleted during the deletion of the source or target entity. Cascade delete algorithm in report needs to be improved
Environment
- OS (where OpenCTI server runs): { e.g. Mac OS 10, Windows 10, Ubuntu 16.4, etc. }
- OpenCTI version: { e.g. OpenCTI 1.0.2 }
- OpenCTI client: { e.g. frontend or python }
- Other environment details:
Reproducible Steps
Steps to create the smallest reproducible scenario:
- Create a report
- Add multiple orphan entities to the report (5-6 entities should be enough)
- Create multiple relationships between those entities (10-12 relationships should be enough)
- Delete the report choosing the cascade delete option
Expected Output
The report and the entities being deleted
Actual Output
An "Already deleted" error is thrown and the report is not deleted
Additional information
Screenshots (optional)
can be reproduced here https://testing.octi.staging.filigran.io/dashboard/analyses/reports/de981984-2576-4275-a6d7-ccac73c2269d