From f1e27ce3131a16bd3cedc638c8230b47e6a551fe Mon Sep 17 00:00:00 2001 From: Valentijn Scholten Date: Sat, 21 Feb 2026 19:50:37 +0100 Subject: [PATCH] Skip dispatching endpoint/location tasks when lists are empty Add early return in chunk_endpoints_and_disperse and chunk_locations_and_disperse when the endpoint/location list is empty. Many parsers (e.g. Bandit) set file_path but leave unsaved_endpoints/unsaved_locations empty, causing ~214 no-op Celery tasks per import. This optimization avoids unnecessary task creation, serialization, and execution. --- dojo/importers/endpoint_manager.py | 2 ++ dojo/importers/location_manager.py | 2 ++ 2 files changed, 4 insertions(+) diff --git a/dojo/importers/endpoint_manager.py b/dojo/importers/endpoint_manager.py index 3f8c3ec817e..8bee966e5ca 100644 --- a/dojo/importers/endpoint_manager.py +++ b/dojo/importers/endpoint_manager.py @@ -114,6 +114,8 @@ def chunk_endpoints_and_disperse( endpoints: list[Endpoint], **kwargs: dict, ) -> None: + if not endpoints: + return dojo_dispatch_task(EndpointManager.add_endpoints_to_unsaved_finding, finding, endpoints, sync=True) @staticmethod diff --git a/dojo/importers/location_manager.py b/dojo/importers/location_manager.py index 82a08c6204d..26c34abf150 100644 --- a/dojo/importers/location_manager.py +++ b/dojo/importers/location_manager.py @@ -84,6 +84,8 @@ def chunk_locations_and_disperse( locations: list[AbstractLocation], **kwargs: dict, ) -> None: + if not locations: + return dojo_dispatch_task(LocationManager.add_locations_to_unsaved_finding, finding, locations, sync=True) @staticmethod