The GitHub Actions job "Tests (AMD)" on 
airflow.git/fix-46402-trigger-dagrun-dynamic-dag-id-links has succeeded.
Run started by GitHub user hwang-cadent (triggered by hwang-cadent).

Head commit for run:
ae34df905135cbe831a982558f6b64b847bb53ce / hwang-cadent <[email protected]>
Fix dynamic dag_id resolution in ``TriggerDagRunOperator`` links

The operator link previously read ``trigger_dag_id`` only from the
operator attribute (and from rendered template fields on AF2). When the
``dag_id`` is resolved at runtime — for example from an XCom pull or a
non-trivial template — the static attribute does not reflect the actual
DAG that was triggered, so the "Triggered DAG" link in the UI points to
the wrong (or non-existent) DAG.

This change stores the resolved ``trigger_dag_id`` in XCom alongside
``trigger_run_id`` after a successful trigger, and updates
``TriggerDagRunLink.get_link()`` to prefer that XCom value before
falling back to the operator attribute / rendered fields.

Notes:

- For Airflow 3.x the XCom is pushed in
  ``task_runner._handle_trigger_dag_run`` (next to ``trigger_run_id``)
  so both values share the same lifecycle and are not written when the
  trigger fails.
- For Airflow 2.x the XCom is pushed in ``_trigger_dag_af_2`` after the
  triggered ``DagRun`` is created.
- ``get_link`` uses an identity check (``trigger_dag_id is None``)
  rather than truthiness so any explicit value pushed to XCom is
  honored.

Tests:

- New ``test_extra_operator_link_with_dynamic_dag_id`` cases (AF2 & AF3)
  verifying the link uses the resolved ``dag_id`` from XCom.
- Existing AF3 ``test_extra_operator_link`` updated to mock
  ``XCom.get_value`` (matches the actual call site).
- ``test_handle_trigger_dag_run`` and
  ``test_handle_trigger_dag_run_wait_for_completion`` updated with the
  new ``SetXCom("trigger_dag_id")`` call in the expected ordered
  sequence, keeping ``assert_has_calls`` ordering guarantees.

Fixes #46402

Report URL: https://github.com/apache/airflow/actions/runs/25602760160

With regards,
GitHub Actions via GitBox


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to