pierrejeambrun commented on code in PR #69403:
URL: https://github.com/apache/airflow/pull/69403#discussion_r3675162547
##########
airflow-core/src/airflow/api_fastapi/execution_api/routes/task_instances.py:
##########
@@ -879,6 +881,42 @@ def _raise_ti_not_in_live_table(task_instance_id: UUID,
session: SessionDep) ->
)
+@ti_id_router.patch(
+ "/{task_instance_id}/dag-run-note",
+ status_code=status.HTTP_204_NO_CONTENT,
+ responses=create_openapi_http_exception_doc(
+ [
+ (status.HTTP_404_NOT_FOUND, "Task Instance not found"),
+ (HTTP_422_UNPROCESSABLE_CONTENT, "Invalid payload for the DagRun
note update"),
+ ]
+ ),
+)
+def update_dag_run_note(
+ task_instance_id: UUID,
+ body: DagRunNoteUpdatePayload,
+ session: SessionDep,
+) -> None:
+ """Update the note for the DagRun associated with this task instance."""
+ bind_contextvars(ti_id=str(task_instance_id))
+
+ dag_run = session.scalar(
+ select(DR)
+ .join(TI, and_(TI.dag_id == DR.dag_id, TI.run_id == DR.run_id))
+ .options(joinedload(DR.dag_run_note))
+ .where(TI.id == task_instance_id)
+ )
+ if dag_run is None:
+ raise HTTPException(
+ status_code=status.HTTP_404_NOT_FOUND,
+ detail={"reason": "not_found", "message": "Task Instance not
found"},
+ )
+
+ # Reuse the public API note logic so both editing paths stay consistent. A
None/empty note
+ # from runtime clears it (removes the row), matching the UI/public API.
Runtime notes carry no
+ # acting user, so they are stored unattributed (user_id=None).
+ patch_dag_run_note(dag_run=dag_run, note=body.note or "", user_id=None)
Review Comment:
There is no 'is not None' gate. So basically this will always clear the note
I believe (sdk path, in opposition to the public API that can 'leave the note
untouched'). If 'none' is passed we shouldn't do anything, and if `""` is
passed, that's the 'clear/remove note' signal.
--
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]