Skip to content

Commit 6835a3b

Browse files
Support sync kwarg in process_findings for inline post-processing
Thread the sync kwarg from process_findings through to dojo_dispatch_task in both DefaultImporter and DefaultReImporter so callers can force post_process_findings_batch to run inline instead of spawning additional Celery tasks. Pop sync from kwargs in sync_process_findings to avoid duplicate keyword argument errors.
1 parent fd042f2 commit 6835a3b

3 files changed

Lines changed: 9 additions & 0 deletions

File tree

dojo/importers/base_importer.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,9 @@ def sync_process_findings(
293293
Processes findings in a synchronous manner such that all findings
294294
will be processed in a worker/process/thread
295295
"""
296+
# Pop sync from kwargs to avoid "multiple values" TypeError when
297+
# callers (e.g. async importer) pass sync=True through the kwargs chain
298+
kwargs.pop("sync", None)
296299
return self.process_findings(parsed_findings, sync=True, **kwargs)
297300

298301
def determine_process_method(

dojo/importers/default_importer.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,8 @@ def process_findings(
167167
# Batched post-processing (no chord): dispatch a task per 1000 findings or on final finding
168168
batch_finding_ids: list[int] = []
169169
batch_max_size = getattr(settings, "IMPORT_REIMPORT_DEDUPE_BATCH_SIZE", 1000)
170+
# Allow callers to force synchronous dispatch of post-processing sub-tasks
171+
sync = kwargs.pop("sync", False)
170172

171173
"""
172174
Saves findings in memory that were parsed from the scan report into the database.
@@ -275,6 +277,7 @@ def process_findings(
275277
product_grading_option=True,
276278
issue_updater_option=True,
277279
push_to_jira=push_to_jira,
280+
sync=sync,
278281
)
279282

280283
# No chord: tasks are dispatched immediately above per batch

dojo/importers/default_reimporter.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,8 @@ def process_findings(
267267
the finding may be appended to a new or existing group based upon user selection
268268
at import time
269269
"""
270+
# Allow callers to force synchronous dispatch of post-processing sub-tasks
271+
sync = kwargs.pop("sync", False)
270272
self.deduplication_algorithm = self.determine_deduplication_algorithm()
271273
# Only process findings with the same service value (or None)
272274
# Even though the service values is used in the hash_code calculation,
@@ -443,6 +445,7 @@ def process_findings(
443445
issue_updater_option=True,
444446
push_to_jira=push_to_jira,
445447
jira_instance_id=getattr(self.jira_instance, "id", None),
448+
sync=sync,
446449
)
447450

448451
# No chord: tasks are dispatched immediately above per batch

0 commit comments

Comments
 (0)