uranusjr commented on a change in pull request #17839:
URL: https://github.com/apache/airflow/pull/17839#discussion_r698323760
##########
File path: airflow/api_connexion/endpoints/dag_run_endpoint.py
##########
@@ -278,19 +280,24 @@ def post_dag_run(dag_id, session):
@security.requires_access(
[
(permissions.ACTION_CAN_READ, permissions.RESOURCE_DAG),
- (permissions.ACTION_CAN_EDIT, permissions.RESOURCE_DAG_RUN)
+ (permissions.ACTION_CAN_EDIT, permissions.RESOURCE_DAG_RUN),
]
)
@provide_session
def post_set_dag_run_state(dag_id: str, dag_run_id: str, session) -> dict:
"""Set a state of a dag run."""
- dag_run: Optional[DagRun] = session.query(DagRun) \
- .filter(DagRun.dag_id == dag_id, DagRun.run_id ==
dag_run_id).one_or_none()
+ dag_run: Optional[DagRun] = (
+ session.query(DagRun).filter(DagRun.dag_id == dag_id, DagRun.run_id ==
dag_run_id).one_or_none()
+ )
if dag_run is None:
error_message = f'Dag Run id {dag_run_id} not found in dag {dag_id}'
raise NotFound(error_message)
+ try:
+ post_body = set_dagrun_state_form_schema.load(request.json,
session=session)
+ except ValidationError as err:
+ raise BadRequest(detail=str(err))
- state = request.json['state']
- dag_run.set_state(state=DagRunState(state.lower()).value)
+ state = post_body['state']
+ dag_run.set_state(state=state)
Review comment:
I think this still needs a conversion
```suggestion
dag_run.set_state(state=DagRunState(state))
```
--
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]