ephraimbuddy commented on code in PR #60011:
URL: https://github.com/apache/airflow/pull/60011#discussion_r2660614043
##########
airflow-core/src/airflow/api_fastapi/core_api/routes/public/dag_run.py:
##########
@@ -138,6 +138,15 @@ def delete_dag_run(dag_id: str, dag_run_id: str, session:
SessionDep):
status.HTTP_404_NOT_FOUND,
f"The DagRun with dag_id: `{dag_id}` and run_id: `{dag_run_id}`
was not found",
)
+
+ # Only allow deletion if dag_run.state is in DAGRunPatchStates
+ allowed_states = {state.value for state in DAGRunPatchStates}
+ if dag_run.state not in allowed_states:
+ raise HTTPException(
+ status.HTTP_400_BAD_REQUEST,
+ f"Cannot delete DagRun in state '{dag_run.state}'. Only allowed in
states: {', '.join(allowed_states)}."
+ )
Review Comment:
I also think we should check that the task instances of the dagrun are in
terminal state and if any is not in terminal state, raise 400.
--
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]