`airflow dags test` sets DagRun.start_date to logical_date causing incorrect run_duration
- Dominant language
- Python
- Stars
- 46.9k
- Forks
- 17.8k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 483
Description
### Under which category would you file this issue?
Airflow Core
### Apache Airflow version
3.2.0
### Under which category would you file this issue?
Airflow Core
### Apache Airflow version
3.2.0
### What happened and how to reproduce it?
## Issue Description
When running `airflow dags test`, the reported `DagRun` metadata appears incorrect.
Specifically:
- `run_start_date` is set to the DAG's logical date
- This causes `run_duration` to be artificially inflated
This happens even with a minimal DAG and without any scheduling or external dependencies.
## Steps to reproduce
1. Create a minimal DAG:
```python
from airflow.sdk import DAG
from airflow.providers.standard.operators.empty import EmptyOperator
from datetime import datetime
with DAG(
dag_id="bug_report_cli_test",
start_date=datetime(2024, 1, 1),
schedule=None,
catchup=False,
):
EmptyOperator(task_id="start")
Run:
airflow dags test bug_report_cli_test 2024-01-01
Run again with current date:
airflow dags test bug_report_cli_test 2026-04-29
Observed behavior
Observed behavior
Example outputs:
DagRun Finished:
logical_date=2024-01-01
run_start_date=2024-01-01
run_end_date=2026-04-29
run_duration=73429309
DagRun Finished:
logical_date=2026-04-29
run_start_date=2026-04-29
run_end_date=2026-04-29 21:04
run_duration=75847
The DAG execution actually takes only a few seconds, but the reported duration is calculated from the logical date instead of the actual execution start time.
This behavior appears specific to airflow dags test and does not reflect the real execution time of the DAG run.
## Screenshots
### Comparison of DagRun output
### Successful DAG execution (short runtime)
### What you think should happen instead?
DagRun.start_date should reflect the actual execution start time of the DAG run, even when using airflow dags test.
As a result, run_duration should represent the real execution duration (a few seconds in this case), not the difference between logical date and execution time.
### Operating System
Ubuntu 24.04.4 LTS
### Deployment
Virtualenv installation
### Apache Airflow Provider(s)
_No response_
### Versions of Apache Airflow Providers
apache-airflow-providers-common-compat==1.14.3
apache-airflow-providers-common-io==1.7.2
apache-airflow-providers-common-sql==1.34.0
apache-airflow-providers-smtp==2.4.5
apache-airflow-providers-standard==1.12.3
### Official Helm Chart version
Not Applicable
### Kubernetes Version
_No response_
### Helm Chart configuration
This issue is fully reproducible with a minimal DAG and occurs consistently.
It does not depend on scheduling, executors, or external systems.
The problem appears specific to `airflow dags test` behavior.
### Docker Image customizations
_No response_
### 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
Research direction
Start by reproducing the issue with the minimal DAG and the two `airflow dags test` commands shown in the report, then trace how the command sets DagRun metadata. Done means `run_start_date` reflects the actual execution start and `run_duration` reflects the short runtime rather than the time since the logical date.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend, cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 58/100