benitezfede opened a new pull request, #53654:
URL: https://github.com/apache/airflow/pull/53654

   closes: #53618 
   related: #52824 
   
   **Description**
   
   - This PR fixes a bug where DAG callbacks (`on_success_callback` and 
`on_failure_callback`) were missing the `dag_run`  object in their context, 
making it impossible for users to access important DAG run information in their 
callback functions.
   
   **Problem**
   
   Currently, when DAG callbacks are executed, the context only contains:
   - `dag`: The DAG object
   - `run_id`: The run ID as a string
   - `reason`: The reason for the callback
   
   This is inconsistent with task callbacks, which have access to the full 
`dag_run` object.
   
   **Solution**
   
   Updated the `handle_dag_callback` method in 
`airflow-core/src/airflow/models/dagrun.py` to include:
   - `dag_run`: The DagRun object (same as task callbacks)
   
   **Changes Made**
   
   - Modified `handle_dag_callback` method: Added `dag_run` to the context 
dictionary.
   - Enhanced tests: Updated existing callback tests to verify the new context 
fields (`dag_run`) are properly populated.
   
   **Testing**
   
   - Added comprehensive tests in `test_dagrun.py` to verify that `dag_run` is 
available in callback contexts.
   - Tests cover both success and failure callbacks
   
   **Breaking Changes**
   
   - None. This is a backward-compatible enhancement that adds missing 
functionality.
   
   **Related Issues**
   
   - Fixes the issue described in GitHub Discussion #53618 and where users 
reported that dag_run was missing from DAG callback contexts.
   
   **Checklist**
   
   [x] My code follows the style guidelines of this project
   [x] I have performed a self-review of my own code
   [x] I have commented my code, particularly in hard-to-understand areas
   [x] I have made corresponding changes to the documentation
   [x] My changes generate no new warnings
   [x] I have added tests that prove my fix is effective or that my feature 
works
   [x] New and existing unit tests pass locally with my changes
   [x] Any dependent changes have been merged and published in downstream 
modules
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to