nothingmin commented on code in PR #54416:
URL: https://github.com/apache/airflow/pull/54416#discussion_r2288720475
##########
airflow-core/src/airflow/api_fastapi/core_api/routes/public/task_instances.py:
##########
@@ -673,13 +674,19 @@ def post_clear_task_instances(
raise HTTPException(status.HTTP_404_NOT_FOUND, error_message)
# Get the specific dag version:
dag = get_dag_for_run(dag_bag, dag_run, session)
- if past or future:
+ if (past or future) and dag_run.logical_date is None:
raise HTTPException(
status.HTTP_400_BAD_REQUEST,
- "Cannot use include_past or include_future when dag_run_id is
provided because logical_date is not applicable.",
+ "Cannot use include_past or include_future with a manually
triggered DAG run (logical_date is None)."
)
- body.start_date = dag_run.logical_date if dag_run.logical_date is not
None else None
- body.end_date = dag_run.logical_date if dag_run.logical_date is not
None else None
+
+ if past or future:
+ body.start_date = dag_run.logical_date if not past else None
+ body.end_date = dag_run.logical_date if not future else None
+ dag_run_id = None # Use date-based clearing
+ else:
+ body.start_date = dag_run.logical_date
+ body.end_date = dag_run.logical_date
Review Comment:
Thanks for the feedback! 🙏
I updated the logic as suggested:
In the dag_run_id branch, I now only initialize both start_date and end_date
with the logical_date.
The past / future handling is left entirely to the common section below,
which nulls out the appropriate bound.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]