apache / apache/airflow

DAGs with future `start_date` are automatically marked as success without executing tasks

Open
#38,513 9 comments 0 reactions 1 assignee Claimed by @amoghrajesh View on GitHub
area:core area:scheduler kind:bug Stale Bug Report
Dominant language
Python
Stars
46.9k
Forks
17.8k
Avg merge
2d 7h
Merged PRs (30d)
484

Description

### Body

For the following DAG:

```
from datetime import datetime

from airflow import DAG
from airflow.operators.bash import BashOperator

default_args = {
'owner': 'airflow',
}

with DAG('my_future_dag',
default_args=default_args,
start_date=datetime(2050, 1, 1),
schedule="@daily",
catchup=False
):
BashOperator(task_id="task1", bash_command="echo 1")
BashOperator(task_id="task2", bash_command="echo 2")
BashOperator(task_id="task3", bash_command="echo 3")
BashOperator(task_id="task4", bash_command="echo 4")
```


As expected no runs will be started till 2050 but I might still want to manually invoke runs. Trying to do so will result in DAGRun marked as success and no tasks being executed as can see


![Screenshot 2024-03-26 at 22 22 42](https://github.com/apache/airflow/assets/45845474/93c2cee0-e3a4-41c4-bc0f-0fbd3bc9da38)

However changing the `start_date` to `datetime(2023, 1, 1)` then tasks are executed as expected for manual runs:
![Screenshot 2024-03-26 at 22 24 28](https://github.com/apache/airflow/assets/45845474/32369453-2036-4e92-ab77-a7ee9ec1b260)

**The bug:**
tasks should be executed for manual runs. The current case where dagrun is marked as success but no tasks are running or reporting failure is wrong.

By the way, a very interesting thing to explore is that if you first deploy the dag with `datetime(2023, 1, 1)` then change it to `datetime(2050, 1, 1)` Airflow has no problem with running tasks with that `start_date`:

![Screenshot 2024-03-26 at 22 28 19](https://github.com/apache/airflow/assets/45845474/7abca52a-3bed-49e4-89fd-6fef8213e747)

![Screenshot 2024-03-26 at 22 29 36](https://github.com/apache/airflow/assets/45845474/832706bd-af4f-418e-b9c6-14c83187ce9b)

### Committer

- [X] I acknowledge that I am a maintainer/committer of the Apache Airflow project.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.