Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Comment thread
potiuk marked this conversation as resolved.
raise HTTPException(
status.HTTP_400_BAD_REQUEST,
detail={
"reason": "value_error",
"message": str(e),
},
) from e


@router.post(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

from __future__ import annotations

import re
from unittest import mock

import pytest
Expand Down Expand Up @@ -322,6 +323,31 @@ async def auth_as_parent_ti(request: Request) -> TIToken:
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):
Expand Down
Loading