apache / apache/airflow

Remove duplicated dag_id and run_id fields from Execution API DagRun schema

Open
#69,935 1 comment 0 reactions 0 assignees View on GitHub
area:API area:core kind:feature
Dominant language
Python
Stars
46.9k
Forks
17.8k
Avg merge
2d 9h
Merged PRs (30d)
472

Description

### Under which category would you file this issue?

Airflow Core

### Apache Airflow version

main

### What happened and how to reproduce it?

**Issue Description**
In the Task Execution API, the `DagRun` schema (used within `TIRunContext` in `airflow-core/src/airflow/api_fastapi/execution_api/datamodels/taskinstance.py`) contains `dag_id` and `run_id` fields. However, these fields are completely redundant because the worker already has the DAG ID and Run ID natively from the `TaskInstance` context.

There is an existing `TODO` comment in the codebase specifically pointing out this duplication:
`# TODO: dag_id and run_id are duplicated from TaskInstance`
`# See if we can avoid sending these fields from API server and instead`
`# use the TaskInstance data to get the DAG run information in the client (Task Execution Interface).`

**Steps to reproduce:**
Inspect the `DagRun` schema defined in `airflow-core/src/airflow/api_fastapi/execution_api/datamodels/taskinstance.py`.

### What you think should happen instead?

We should remove the `dag_id` and `run_id` fields from the `DagRun` model in the API server to streamline the payload. The Task SDK client should be updated to rely on the `TaskInstance` identifiers instead of expecting them to be nested in the `DagRun` payload.

I'd be happy to submit a PR to resolve this `TODO`!

### Operating System

Not Applicable

### Deployment

None

### Apache Airflow Provider(s)

_No response_

### Versions of Apache Airflow Providers

Not Applicable

### Official Helm Chart version

Not Applicable

### Kubernetes Version

Not Applicable

### Helm Chart configuration

Not Applicable

### Docker Image customizations

Not Applicable

### Anything else?

_No response_

### Are you willing to submit PR?

- [x] Yes I am willing to submit a PR!

### Code of Conduct

- [x] I agree to follow this project's [Code of Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)

Contributor guide

Open the contributing guide

Research direction

Start in airflow-core/src/airflow/api_fastapi/execution_api/datamodels/taskinstance.py at the DagRun schema and its TODO, then trace TIRunContext and Task SDK uses of dag_id and run_id. Update the API and client consistently, and verify that the execution API and Task SDK no longer depend on those fields nested in DagRun.

Written by the indexing model from the issue text.

Assessment

Tech stack
fastapi, python
Domain
api, backend
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.