Lee-W commented on code in PR #51295:
URL: https://github.com/apache/airflow/pull/51295#discussion_r2122808752
##########
airflow-core/src/airflow/api_fastapi/execution_api/routes/task_instances.py:
##########
@@ -374,39 +377,79 @@ 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:
+ if isinstance(err, HTTPException) and err.status_code ==
status.HTTP_422_UNPROCESSABLE_ENTITY:
+ # We need to rebuild the query and remove "reschedule_date"which
causes DB error
+ data = ti_patch_payload.model_dump(exclude={"reschedule_date"},
exclude_unset=True)
+ query = update(TI).where(TI.id == ti_id_str).values(data)
Review Comment:
mysql limitation. it will be moved into
`_create_ti_state_update_query_and_update_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]