This is an automated email from the ASF dual-hosted git repository. ephraimanierobi pushed a commit to branch v2-4-test in repository https://gitbox.apache.org/repos/asf/airflow.git
commit ef86a455ab63fc38cb47e23b7c9a177d571dc5d6 Author: jordanjeremy <[email protected]> AuthorDate: Mon Nov 7 17:07:58 2022 -0600 Fix getting the dag/task ids from base executor (#27550) (cherry picked from commit f304df7857eea344a7c274dcf41bbe5271a0083f) --- airflow/executors/base_executor.py | 2 +- tests/executors/test_base_executor.py | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/airflow/executors/base_executor.py b/airflow/executors/base_executor.py index 1d1b0e2cf7..70b65f40e1 100644 --- a/airflow/executors/base_executor.py +++ b/airflow/executors/base_executor.py @@ -364,7 +364,7 @@ class BaseExecutor(LoggingMixin): if len(command) > 3 and "--help" not in command: dag_id: str | None = None task_id: str | None = None - for arg in command[4:]: + for arg in command[3:]: if not arg.startswith("--"): if dag_id is None: dag_id = arg diff --git a/tests/executors/test_base_executor.py b/tests/executors/test_base_executor.py index 5d0f22dab4..fee53d35ab 100644 --- a/tests/executors/test_base_executor.py +++ b/tests/executors/test_base_executor.py @@ -125,3 +125,10 @@ def test_trigger_running_tasks(dag_maker, change_state_attempt): assert len(executor.execute_async.mock_calls) == len(dagrun.task_instances) + 1 else: assert len(executor.execute_async.mock_calls) == len(dagrun.task_instances) + + +def test_validate_airflow_tasks_run_command(dag_maker): + dagrun = setup_dagrun(dag_maker) + tis = dagrun.task_instances + dag_id, task_id = BaseExecutor.validate_airflow_tasks_run_command(tis[0].command_as_list()) + assert dag_id == dagrun.dag_id and task_id == tis[0].task_id
