jason810496 commented on code in PR #58921:
URL: https://github.com/apache/airflow/pull/58921#discussion_r2616133337
##########
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:
As we are migrating to SQLA 2, it seems the `getattr` is still required to
avoid the MyPy error if we bump the SQLA version.
https://github.com/apache/airflow/pull/57277/changes#diff-072241d81275cd4b4b867f51025e9dca800610069305cffeb4b77ad45e135557R2320-R2321
https://github.com/apache/airflow/pull/58905/changes#diff-a293f2e3bfda39f00a5b8a11254d49c9fed90b0ec6a35ee6269be2d95511f34fR67-R69
--
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]