nathadfield commented on code in PR #67273:
URL: https://github.com/apache/airflow/pull/67273#discussion_r3441207652


##########
airflow-core/src/airflow/api_fastapi/execution_api/routes/dag_runs.py:
##########
@@ -30,6 +30,7 @@
 from airflow.api_fastapi.common.db.common import SessionDep
 from airflow.api_fastapi.common.types import UtcDateTime
 from airflow.api_fastapi.compat import HTTP_422_UNPROCESSABLE_CONTENT
+from airflow.api_fastapi.core_api.services.public.common import 
resolve_run_on_latest_version

Review Comment:
   Good catch. I've moved `resolve_run_on_latest_version` into 
`airflow.api_fastapi.common.dagbag` and repointed all the callers so the 
execution API no longer reaches into `core_api.services`.



##########
airflow-core/tests/unit/api_fastapi/execution_api/versions/head/test_dag_runs.py:
##########
@@ -322,6 +324,27 @@ def test_dag_run_not_found(self, client):
 
         assert response.status_code == 404
 
+    def test_dag_run_clear_invokes_resolver(self, client, session, dag_maker):
+        """Clearing invokes resolve_run_on_latest_version with no explicit 
override."""
+        dag_id = "test_clear_invokes_resolver"
+        run_id = "test_run_id"
+
+        with dag_maker(dag_id=dag_id, session=session, serialized=True):
+            EmptyOperator(task_id="test_task")
+        dag_maker.create_dagrun(run_id=run_id, state=DagRunState.SUCCESS)
+        session.commit()
+
+        with mock.patch(
+            
"airflow.api_fastapi.execution_api.routes.dag_runs.resolve_run_on_latest_version",
+            return_value=False,
+        ) as mock_resolver:
+            response = 
client.post(f"/execution/dag-runs/{dag_id}/{run_id}/clear")
+
+        assert response.status_code == 204
+        mock_resolver.assert_called_once()

Review Comment:
   Agreed. I've updated the test to spy on `SerializedDAG.clear` and assert the 
resolved value is actually passed through as `run_on_latest_version`, so it now 
catches the dropped-value case rather than just checking the resolver was 
called.



-- 
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]

Reply via email to