refactor: rename dispatch kwarg sync= to force_sync=#14882
Open
valentijnscholten wants to merge 1 commit into
Open
refactor: rename dispatch kwarg sync= to force_sync=#14882valentijnscholten wants to merge 1 commit into
valentijnscholten wants to merge 1 commit into
Conversation
The `sync=True` kwarg on dojo_dispatch_task / dojo_async_task forces the target task to run in the foreground. The bare name `sync` collides with unrelated `sync` parameters elsewhere in the codebase (e.g. JIRA Instance's `finding_jira_sync`, `is_keep_in_sync`) and is asymmetric with the recently-introduced `force_async=True` knob. Rename to `force_sync=` for clarity and symmetry. Hard rename — no alias. Callers updated: - dojo/decorators.py — we_want_async reads `force_sync` instead of `sync`. - dojo/celery_dispatch.py — docstring. - dojo/celery.py — DojoAsyncTask.apply_async pops `force_sync` from kwargs. - dojo/importers/default_importer.py, default_reimporter.py — propagate `force_sync` from importer kwargs to post_process_findings_batch. - dojo/finding/helper.py — post_process_findings_batch signature + nested dojo_dispatch_task(calculate_grade, ..., force_sync=force_sync). - dojo/api_v2/serializers.py, dojo/finding_group/views.py — JIRA push call sites that want foreground execution. - unittests/test_async_delete.py, test_reimport_prefetch.py, test_update_import_history.py — updated kwargs + docstrings.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
force_asyncwhich made me realize we should useforce_sync=Trueinstead ofsync=True. IS more explicit and clear what it does.sync=→force_sync=ondojo_dispatch_task/dojo_async_task/we_want_async.Why
synccollides with unrelated parameters elsewhere in the codebase (e.g.JIRA_Instance.finding_jira_sync,is_keep_in_sync, scan types named "HawkScan"), making code search and review confusing.force_async=Truekwarg solves the inverse problem (always run in background).force_syncis the symmetric, intention-revealing name for the existing flag — readers instantly know what "force" means relative to the default async-when-possible behavior.Changes
Caller / dispatch chain:
we_want_asyncreadsforce_syncfrom kwargs.DojoAsyncTask.apply_asyncpopsforce_sync(control flag, never reaches the task body).force_syncfrom importer kwargs topost_process_findings_batch.post_process_findings_batchsignature + nesteddojo_dispatch_task(calculate_grade, ..., force_sync=force_sync).Tests:
Test plan
ruff checkclean on all changed files.pytest unittests/test_async_delete.py::TestAsyncDelete::test_async_delete_accepts_force_sync_kwarg— passes.test_reimport_prefetch.pyreproduce ondevbaseline → not caused by this change (verified by stashing the diff and re-running).Notes
dojo/decorators.pysince both touchwe_want_async. Whichever merges second rebases.