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


##########
airflow-core/src/airflow/api_fastapi/execution_api/routes/xcoms.py:
##########
@@ -482,3 +484,39 @@ def delete_xcom(
     )
     session.execute(query)
     return {"message": f"XCom with key: {key} successfully deleted."}
+
+
[email protected](
+    "/{dag_id}/{run_id}",
+    description="Bulk delete XCom values.",
+)
+def bulk_delete_xcoms(
+    session: SessionDep,
+    dag_id: str,
+    run_id: str,
+    task_id: Annotated[str | None, Query()] = None,
+    key: Annotated[str | None, Query()] = None,
+    map_index: Annotated[int | None, Query()] = None,
+    include_dag_result: Annotated[bool, Query()] = False,
+) -> int:
+    """Bulk delete XCom values."""
+    dag_run_id = session.scalar(select(DagRun.id).where(DagRun.dag_id == 
dag_id, DagRun.run_id == run_id))
+    if dag_run_id is None:
+        return 0
+
+    query = delete(XComModel).where(XComModel.dag_run_id == dag_run_id)
+
+    if not include_dag_result:
+        query = query.where(XComModel.dag_result.isnot(True))

Review Comment:
   `include_dag_result` defaulting to False may catch users off guard. 
Defaulting to True seems more natural to me. If we really want to default this 
to False, this needs to be described more prominently in API documentation.



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