Repository navigation
Closed
Labels
Description
Apache Airflow version
Other Airflow 3 version (please specify below)
If "Other Airflow 3 version" selected, which one?
3.1.5
What happened?
I tried to clear dag and rerun dags that had run in 3.0.6 and I got the following error:
airflow db clear -t dag_runs ...
Traceback (most recent call last):
File "/home/airflow/.local/lib/python3.11/site-packages/airflow/jobs/scheduler_job_runner.py", line 1079, in _execute
self._run_scheduler_loop()
File "/home/airflow/.local/lib/python3.11/site-packages/airflow/jobs/scheduler_job_runner.py", line 1369, in _run_scheduler_loop
num_queued_tis = self._do_scheduling(session)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/airflow/.local/lib/python3.11/site-packages/airflow/jobs/scheduler_job_runner.py", line 1479, in _do_scheduling
callback_tuples = self._schedule_all_dag_runs(guard, dag_runs, session)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/airflow/.local/lib/python3.11/site-packages/airflow/utils/retries.py", line 97, in wrapped_function
for attempt in run_with_db_retries(max_retries=retries, logger=logger, **retry_kwargs):
File "/home/airflow/.local/lib/python3.11/site-packages/tenacity/__init__.py", line 445, in __iter__
do = self.iter(retry_state=retry_state)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/airflow/.local/lib/python3.11/site-packages/tenacity/__init__.py", line 378, in iter
result = action(retry_state)
^^^^^^^^^^^^^^^^^^^
File "/home/airflow/.local/lib/python3.11/site-packages/tenacity/__init__.py", line 400, in <lambda>
self._add_action_func(lambda rs: rs.outcome.result())
^^^^^^^^^^^^^^^^^^^
File "/usr/python/lib/python3.11/concurrent/futures/_base.py", line 449, in result
return self.__get_result()
^^^^^^^^^^^^^^^^^^^
File "/usr/python/lib/python3.11/concurrent/futures/_base.py", line 401, in __get_result
raise self._exception
File "/home/airflow/.local/lib/python3.11/site-packages/airflow/utils/retries.py", line 106, in wrapped_function
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/home/airflow/.local/lib/python3.11/site-packages/airflow/jobs/scheduler_job_runner.py", line 1921, in _schedule_all_dag_runs
callback_tuples = [(run, self._schedule_dag_run(run, session=session)) for run in dag_runs]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/airflow/.local/lib/python3.11/site-packages/airflow/jobs/scheduler_job_runner.py", line 1921, in <listcomp>
callback_tuples = [(run, self._schedule_dag_run(run, session=session)) for run in dag_runs]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/airflow/.local/lib/python3.11/site-packages/airflow/jobs/scheduler_job_runner.py", line 2037, in _schedule_dag_run
schedulable_tis, callback_to_run = dag_run.update_state(session=session, execute_callbacks=False)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/airflow/.local/lib/python3.11/site-packages/airflow/utils/session.py", line 98, in wrapper
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/home/airflow/.local/lib/python3.11/site-packages/airflow/models/dagrun.py", line 1184, in update_state
context_from_server=DagRunContext(
^^^^^^^^^^^^^^
File "/home/airflow/.local/lib/python3.11/site-packages/pydantic/main.py", line 250, in __init__
validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pydantic_core._pydantic_core.ValidationError: 1 validation error for DagRunContext
dag_run.start_date
Input should be a valid datetime [type=datetime_type, input_value=None, input_type=NoneType]
For further information visit https://errors.pydantic.dev/2.12/v/datetime_type
What you think should happen instead?
Dags should be allowed to be restarted withouth any issues
How to reproduce
Have dags that had previously run in 3.0.6 .
Upgrade to 3.1.5
Do a call to the clear dag run api
Error will appear
Operating System
Debian GNU/Linux 12 (bookworm)
Versions of Apache Airflow Providers
No response
Deployment
Official Apache Airflow Helm Chart
Deployment details
No response
Anything else?
No response
Are you willing to submit PR?
- Yes I am willing to submit a PR!
Code of Conduct
- I agree to follow this project's Code of Conduct
Activity
DonHaul commentedon Feb 3, 2026
using
airflow db clearto remove older dag runs worked as a temporary fixv4xsh commentedon Feb 4, 2026
I’d like to take ownership of this issue and work on a fix.
From the traceback, this appears to be a regression tied to stricter Pydantic v2 validation introduced in Airflow 3.1.5. The
DagRunContextmodel expectsdag_run.start_dateto be a validdatetime, but DAG runs (especially those cleared or migrated from legacy versions like 3.0.6) can legitimately havestart_date=Nonein the database. When the scheduler attempts to construct the context for these runs, it triggers aValidationError.This seems to be a backward-compatibility gap in the core scheduling logic rather than a user configuration error.
Proposed Approach:
start_dateinDagRunContextshould be changed toOptional[datetime]to accommodate cleared states.scheduler_job_runner.pybefore the model is instantiated during reruns.ValidationError.I can try to reproduce this locally on my environment and am ready to implement the fix once there is a consensus on the preferred path. I would appreciate being assigned to this issue.
gyli commentedon Feb 13, 2026
Thanks @v4xsh, issue is assigned to you
v4xsh commentedon Feb 16, 2026
Hi @gyli,
Thank you for assigning this to me — I really appreciate it.
Apologies for the slight delay, I was busy last week with exams. I’ll start working on it now.
v4xsh commentedon Feb 16, 2026
Hi @gyli,
I’ve opened a PR to address this issue:
Allow null
start_datein DagRun Pydantic model to fix rerun regression (#61981)The fix updates the
DagRunPydantic model to allowstart_date=None, which aligns it with the database/ORM behavior for cleared and queued runs. I’ve also added unit tests to cover both:DagRunvalidation withstart_date=NoneDagRunContextconstruction used by the schedulerPlease let me know if any adjustments are needed.
Thanks!
potiuk commentedon Mar 2, 2026
@v4xsh We are unassigning you from this issue as part of our updated assignment policy.
This is not meant to discourage your contribution — quite the opposite! You are still very welcome to work on this issue and submit a PR for it. Simply comment that you are working on it and open a PR when ready.
We found that formal assignments were not working well, as they often prevented others from contributing when the assignee was not actively working on the issue.
v4xsh commentedon Mar 2, 2026
Hi @potiuk — thanks for the clarification.
I’m actively working on this and have already opened PR #61981.
Happy to make any changes needed.
DonHaul commentedon Apr 9, 2026
Closing as it seems to have been solved in: #58175