dheerajturaga commented on code in PR #58921:
URL: https://github.com/apache/airflow/pull/58921#discussion_r2616079949
##########
airflow-core/src/airflow/api_fastapi/core_api/routes/public/xcom.py:
##########
@@ -336,6 +335,47 @@ def update_xcom_entry(
)
# Update XCom entry
- xcom_entry.value = json.dumps(xcom_new_value)
+ xcom_entry.value = json.dumps(patch_body.value)
return XComResponseNative.model_validate(xcom_entry)
+
+
+@xcom_router.delete(
+ "/{xcom_key:path}",
+ status_code=status.HTTP_204_NO_CONTENT,
+ responses=create_openapi_http_exception_doc(
+ [
+ status.HTTP_400_BAD_REQUEST,
+ status.HTTP_404_NOT_FOUND,
+ ]
+ ),
+ dependencies=[
+ Depends(action_logging()),
+ Depends(requires_access_dag(method="DELETE",
access_entity=DagAccessEntity.XCOM)),
+ ],
+)
+def delete_xcom_entry(
+ dag_id: str,
+ task_id: str,
+ dag_run_id: str,
+ xcom_key: str,
+ session: SessionDep,
+ map_index: Annotated[int, Query(ge=-1)] = -1,
+):
+ """Delete an XCom entry."""
+ # Delete XCom entry
+ result = session.execute(
+ delete(XComModel).where(
+ XComModel.dag_id == dag_id,
+ XComModel.task_id == task_id,
+ XComModel.run_id == dag_run_id,
+ XComModel.key == xcom_key,
+ XComModel.map_index == map_index,
+ )
+ )
+
+ if result.rowcount == 0:
Review Comment:
Thanks for the review and approval!
regarding this change, I dont think we should do this. The proposed change
inverts the logic (it would raise 404 when rows ARE deleted instead of when
they aren't) and result.rowcount is a standard SQLAlchemy pattern used
throughout the codebase without defensive getattr.
--
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]