Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion airflow-core/src/airflow/models/taskinstance.py
Original file line number Diff line number Diff line change
Expand Up @@ -1005,7 +1005,10 @@ def get_dagrun(self, session: Session = NEW_SESSION) -> DagRun:
:return: DagRun
"""
info: Any = inspect(self)
if info.attrs.dag_run.loaded_value is not NO_VALUE:
# If dag_run is loaded and not None, return it.
# In early lifecycle phases (e.g. task_instance_mutation_hook),
# dag_run may be marked as loaded but still be None.
if info.attrs.dag_run.loaded_value is not NO_VALUE and self.dag_run is not None:
if getattr(self, "task", None) is not None:
if TYPE_CHECKING:
assert self.task
Expand Down