This is an automated email from the ASF dual-hosted git repository.

kaxil pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new bc033da913d Handle ValueError for `trigger_dag_run` API request 
(#67601)
bc033da913d is described below

commit bc033da913d78983e07c64fbadff2750b3ba5cf1
Author: Maksim <[email protected]>
AuthorDate: Thu Jul 30 15:54:58 2026 +0200

    Handle ValueError for `trigger_dag_run` API request (#67601)
---
 .../api_fastapi/execution_api/routes/dag_runs.py   |  8 +++++++
 .../execution_api/versions/head/test_dag_runs.py   | 26 ++++++++++++++++++++++
 2 files changed, 34 insertions(+)

diff --git 
a/airflow-core/src/airflow/api_fastapi/execution_api/routes/dag_runs.py 
b/airflow-core/src/airflow/api_fastapi/execution_api/routes/dag_runs.py
index 31aeb96c63e..00a9ab37f25 100644
--- a/airflow-core/src/airflow/api_fastapi/execution_api/routes/dag_runs.py
+++ b/airflow-core/src/airflow/api_fastapi/execution_api/routes/dag_runs.py
@@ -163,6 +163,14 @@ def trigger_dag_run(
             status.HTTP_400_BAD_REQUEST,
             detail={"reason": "invalid_partition_key", "message": str(e)},
         ) from e
+    except ValueError as e:
+        raise HTTPException(
+            status.HTTP_400_BAD_REQUEST,
+            detail={
+                "reason": "value_error",
+                "message": str(e),
+            },
+        ) from e
 
 
 @router.post(
diff --git 
a/airflow-core/tests/unit/api_fastapi/execution_api/versions/head/test_dag_runs.py
 
b/airflow-core/tests/unit/api_fastapi/execution_api/versions/head/test_dag_runs.py
index 5bd6d6b36e3..cd78af871c5 100644
--- 
a/airflow-core/tests/unit/api_fastapi/execution_api/versions/head/test_dag_runs.py
+++ 
b/airflow-core/tests/unit/api_fastapi/execution_api/versions/head/test_dag_runs.py
@@ -17,6 +17,7 @@
 
 from __future__ import annotations
 
+import re
 from unittest import mock
 
 import pytest
@@ -322,6 +323,31 @@ class TestDagRunTrigger:
         child_run = session.scalars(select(DagRun).where(DagRun.run_id == 
child_run_id)).one()
         assert child_run.triggering_user_name == parent_triggering_user_name
 
+    def test_trigger_dag_run_value_error(self, client, session, dag_maker):
+        """Test that error is raised when a DAG Run has ValueError."""
+
+        dag_id = "test_trigger_dag_run_value_error"
+        run_id = "manual__{test_run_id}"
+        logical_date = timezone.datetime(2026, 5, 22)
+
+        with dag_maker(dag_id=dag_id, session=session, serialized=True):
+            EmptyOperator(task_id="test_task")
+
+        session.commit()
+
+        response = client.post(
+            f"/execution/dag-runs/{dag_id}/{run_id}",
+            json={"logical_date": logical_date.isoformat()},
+        )
+
+        detail_message = response.json()["detail"]["message"]
+        detail_reason = response.json()["detail"]["reason"]
+
+        pattern = r"The run_id provided '.*' does not match regex pattern '.*' 
or '.*'"
+        assert re.search(pattern, detail_message)
+        assert detail_reason == "value_error"
+        assert response.status_code == 400
+
 
 class TestDagRunClear:
     def setup_method(self):

Reply via email to