amoghrajesh commented on code in PR #44241:
URL: https://github.com/apache/airflow/pull/44241#discussion_r1856572847


##########
airflow/api_fastapi/execution_api/routes/task_instances.py:
##########
@@ -122,6 +124,53 @@ def ti_update_state(
         )
     elif isinstance(ti_patch_payload, TITerminalStatePayload):
         query = TI.duration_expression_update(ti_patch_payload.end_date, 
query, session.bind)
+    elif isinstance(ti_patch_payload, TIDeferredStatePayload):
+        trigger_row = Trigger(
+            classpath=ti_patch_payload.classpath,
+            kwargs=ti_patch_payload.kwargs,
+            created_date=ti_patch_payload.created_date,
+        )
+        session.add(trigger_row)
+        session.flush()

Review Comment:
   On checking further, I realised that it is not needed. The get_session 
context manager will handle it. The reason it was added was for the unit test 
portion.
   
   After adding a session.commit to the unit test after calling the patch 
ideally represents the API and it works as expected.
   
   ```
               payload = {
                   "state": "deferred",
                   "classpath": "my-class-path",
                   "kwargs": {"key": "value"},
                   "next_method": "execute_callback",
                   "timeout": "P1D",
               }
   
               response = 
client.patch(f"/execution/task-instances/{ti.id}/state", json=payload)
   
               assert response.status_code == 204
               assert response.text == ""
   
               session.commit()
               session.expire_all()
   ```



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