apache / apache/airflow

Default parameter can create a new version of DAG after every run

Open
#56,319 5 comments 1 reaction 0 assignees View on GitHub
area:core kind:bug kind:feature needs-triage
Dominant language
Python
Stars
46.9k
Forks
17.8k
Avg merge
2d 10h
Merged PRs (30d)
483

Description

### Description

Using below `Param` with default value as today's date as mentioned in the [official doc](https://airflow.apache.org/docs/apache-airflow/stable/core-concepts/params.html#use-params-to-provide-a-trigger-ui-form) will create a new DAG version as part of every run on a different day.
```
Param(f"{datetime.date.today()}", type="string", format="date")
```

The issue gets even worse if you accidentally use `time.time()` as the default parameter.

We should also add a `ruff lint` check to catch this.

### Use case/motivation

- Avoid accidental version creation as `serialized_dag` table can become really heavy
- Official docs recommend this, but I think either it shouldn't create a version or there should be some other best practice for dates

### Related issues

A lot of versions get created for the DAG even though engineer didn't update DAG's code

### Are you willing to submit a PR?

- [ ] 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 with the Params documentation linked in the issue and trace how dynamic Param defaults affect the serialized_dag table and DAG versioning. Then investigate whether a Ruff lint check is feasible; done should prevent or clearly address unintended version creation from values such as today’s date or time.time().

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data-engineering
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.