Skip to content

No dag run/context in task_instance_mutation_hook #60610

@devgonvarun

Description

@devgonvarun

Apache Airflow version

Other Airflow 3 version (please specify below)

If "Other Airflow 3 version" selected, which one?

3.1.3

What happened?

The task_instance_mutation_hook provides the TaskInstance object using which one should be able to call the dag_run or get_dagrun() to obtain the DagRun object but they return None. Also there is no way to obtain the context through this TaskInstance. So its not possible to implement logic that makes use of a Params value obtained from manual dag trigger configs.

What you think should happen instead?

task_instance_mutation_hook's TaskInstance should either give access to the valid DagRun.conf or the context object so the Param value passed from manual trigger can be read inside the hook. dag_run or get_dagrun() from the hook's TaskInstance should not return None or fail.

How to reproduce

Create a Param in the Dag code. Manually trigger the dag with the Advanced options and pass the Param value with your dag run. Try to access your passed Param value in the task_instance_mutation_hook.

Operating System

Debian GNU/Linux 12 (bookworm)

Versions of Apache Airflow Providers

No response

Deployment

Official Apache Airflow Helm Chart

Deployment details

No response

Anything else?

No response

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions