You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2021/10/01 14:47:55 UTC

[GitHub] [airflow] ashb commented on a change in pull request #18642: Ensure task_instance exist before running update on its state(REST API)

ashb commented on a change in pull request #18642:
URL: https://github.com/apache/airflow/pull/18642#discussion_r720312043



##########
File path: airflow/api_connexion/endpoints/task_instance_endpoint.py
##########
@@ -286,9 +286,14 @@ def post_set_task_instances_state(dag_id, session):
         error_message = f"Task ID {task_id} not found"
         raise NotFound(error_message)
 
+    execution_date = data['execution_date']
+    ti = session.query(TI).filter_by(execution_date=execution_date, task_id=task_id, dag_id=dag_id).first()

Review comment:
       ```suggestion
       ti = session.query(TI).filter_by(execution_date=execution_date, task_id=task_id, dag_id=dag_id).one_or_none()
   ```




-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org