uranusjr commented on code in PR #51295:
URL: https://github.com/apache/airflow/pull/51295#discussion_r2122401837


##########
airflow-core/src/airflow/api_fastapi/execution_api/routes/task_instances.py:
##########
@@ -374,39 +377,78 @@ def ti_update_state(
 
     # We exclude_unset to avoid updating fields that are not set in the payload
     data = ti_patch_payload.model_dump(exclude={"task_outlets", 
"outlet_events"}, exclude_unset=True)
-
     query = update(TI).where(TI.id == ti_id_str).values(data)
 
-    if isinstance(ti_patch_payload, TITerminalStatePayload):
-        updated_state = ti_patch_payload.state
-        query = TI.duration_expression_update(ti_patch_payload.end_date, 
query, session.bind)
-        query = query.values(state=updated_state)
+    try:
+        query, updated_state = _create_ti_state_update_query_and_update_state(
+            ti_patch_payload=ti_patch_payload,
+            ti_id_str=ti_id_str,
+            dag_bag=dag_bag,
+            session=session,
+            query=query,
+            updated_state=updated_state,
+            dag_id=dag_id,
+        )
+    except Exception as err:
+        # This is an expected exception for MySQL
+        if isinstance(err, HTTPException) and err.status_code == 
status.HTTP_422_UNPROCESSABLE_ENTITY:
+            raise

Review Comment:
   What happens after this is reraised? Should we just catch it like everything 
else?



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