Skip to content

Conversation

@Asquator
Copy link

@Asquator Asquator commented Jan 31, 2026

DRAFT

This PR strives to make sense out of TI contexts passed to Dag callbacks. Rather than always passing the last task lexicogrpahically, the new logic passes the last "relevant" task to Dag's failure.


Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)
    deepwiki.com was used to find the relevant logic in the repo, and an embedded chat was used to make a skeleton for TestDagRunGetFirstTiCausingFailure.

  • Read the Pull Request Guidelines for more information. Note: commit author/co-author name and email in commits become permanently public when merged.
  • For fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
  • When adding dependency, check compliance with the ASF 3rd Party License Policy.
  • For significant user-facing changes create newsfragment: {pr_number}.significant.rst or {issue_number}.significant.rst, in airflow-core/newsfragments.

@Asquator Asquator requested review from XD-DENG and ashb as code owners January 31, 2026 00:33
@boring-cyborg boring-cyborg bot added the area:Scheduler including HA (high availability) scheduler label Jan 31, 2026
@Asquator Asquator changed the title Always provide a relevant task instance in Dag callback Always provide a relevant TI context in Dag callback Jan 31, 2026
.where(TI.dag_id == dag_run.dag_id)
.where(TI.run_id == dag_run.run_id)
.where(TI.state.in_(State.unfinished))
.where(TI.state.in_(State.unfinished) | (TI.state.is_(None)))
Copy link
Author

@Asquator Asquator Jan 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought that tasks with null state should also be always marked as skipped (the in_ clause won't fetch them because of SQL semantics).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:Scheduler including HA (high availability) scheduler

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DAG on_failure_callback uses wrong context

1 participant