Skip to content

Commit f67196c

Browse files
Skip dispatching endpoint/location tasks when lists are empty (#14361)
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.
1 parent 8161bc2 commit f67196c

2 files changed

Lines changed: 4 additions & 0 deletions

File tree

dojo/importers/endpoint_manager.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@ def chunk_endpoints_and_disperse(
114114
endpoints: list[Endpoint],
115115
**kwargs: dict,
116116
) -> None:
117+
if not endpoints:
118+
return
117119
dojo_dispatch_task(EndpointManager.add_endpoints_to_unsaved_finding, finding, endpoints, sync=True)
118120

119121
@staticmethod

dojo/importers/location_manager.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ def chunk_locations_and_disperse(
8484
locations: list[AbstractLocation],
8585
**kwargs: dict,
8686
) -> None:
87+
if not locations:
88+
return
8789
dojo_dispatch_task(LocationManager.add_locations_to_unsaved_finding, finding, locations, sync=True)
8890

8991
@staticmethod

0 commit comments

Comments
 (0)