GitHub user TongyiDai added a comment to the discussion: Date strings in DAG
params
There is no way for one value to be both “today at trigger time” and a stable
parse-time Param default. Airflow must serialize the Param default to build the
trigger form and DAG version; a Jinja expression in the default is therefore
displayed as literal text rather than rendered against a future DagRun.
The warning is correctly telling you that `current_date` changes the serialized
DAG on every parse. The stable choices are:
1. Use a fixed/nullable string default and let manual users enter the version:
`Param(None, type=["null", "string"], title="Output version")`
Then inside the task compute `params["output_version"] or
logical_date.strftime("%y%m%d")`.
2. If this value is only consumed by templated operator fields, pass the
fallback there, for example:
`{{ params.output_version or logical_date.strftime('%y%m%d') }}`
3. If you require the trigger form itself to be pre-populated with the
wall-clock date at the moment the user opens it, Airflow's static Param schema
does not support that. A small task/callback or an external trigger UI/API must
supply it.
This keeps DAG construction deterministic and stops version inflation while
preserving user overrides. Also prefer `logical_date`/data-interval semantics
to `datetime.now()` for scheduled runs; “today” and the run's logical date are
not necessarily the same.
GitHub link:
https://github.com/apache/airflow/discussions/73128#discussioncomment-18459885
----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: [email protected]