hkc-8010 commented on code in PR #69403:
URL: https://github.com/apache/airflow/pull/69403#discussion_r3627339897
##########
airflow-core/src/airflow/api_fastapi/execution_api/routes/task_instances.py:
##########
@@ -860,6 +861,43 @@ def ti_skip_downstream(
log.info("Downstream tasks skipped", tasks_skipped=getattr(result,
"rowcount", 0))
+@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"},
+ )
+
+ if dag_run.dag_run_note is None:
Review Comment:
Switched the runtime endpoint to reuse `patch_dag_run_note` and made its
attribution optional (`user_id: str | None`), so set/update/clear lives in one
place. A runtime clear (empty or null note) now removes the `dag_run_note` row
like the UI/public API path, instead of leaving a NULL-content row. Updated the
three existing callers to pass `user_id=user.get_id()` and the clear test now
asserts the row is gone.
--
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]