This is an automated email from the ASF dual-hosted git repository.

vincbeck pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new 5e23c6a0cc8 Remove redundant session.commit() calls in FastAPI route 
handlers (#69495)
5e23c6a0cc8 is described below

commit 5e23c6a0cc8d5d3ca9d329b7b3e4c3c87deee2e1
Author: Kushagra Gupta <[email protected]>
AuthorDate: Tue Jul 7 22:30:19 2026 +0530

    Remove redundant session.commit() calls in FastAPI route handlers (#69495)
    
    The database session in the FastAPI layer is injected via the SessionDep 
dependency, which automatically commits the transaction when a request 
completes successfully. Explicitly calling session.commit() inside the route 
handler is redundant and circumvents the dependency's intended transaction 
lifecycle management. This brings the route handlers in line with the codebase 
guideline that prohibits functions accepting a session parameter from calling 
commit.
---
 .../src/airflow/api_fastapi/core_api/routes/public/backfills.py         | 1 -
 airflow-core/src/airflow/api_fastapi/core_api/routes/public/hitl.py     | 2 --
 airflow-core/src/airflow/api_fastapi/execution_api/routes/hitl.py       | 1 -
 airflow-core/src/airflow/api_fastapi/execution_api/routes/xcoms.py      | 1 -
 4 files changed, 5 deletions(-)

diff --git 
a/airflow-core/src/airflow/api_fastapi/core_api/routes/public/backfills.py 
b/airflow-core/src/airflow/api_fastapi/core_api/routes/public/backfills.py
index 70c353fb7a2..dcfba919465 100644
--- a/airflow-core/src/airflow/api_fastapi/core_api/routes/public/backfills.py
+++ b/airflow-core/src/airflow/api_fastapi/core_api/routes/public/backfills.py
@@ -136,7 +136,6 @@ def pause_backfill(backfill_id: NonNegativeInt, session: 
SessionDep) -> Backfill
         raise HTTPException(status.HTTP_409_CONFLICT, "Backfill is already 
completed.")
     if b.is_paused is False:
         b.is_paused = True
-    session.commit()
     return b
 
 
diff --git 
a/airflow-core/src/airflow/api_fastapi/core_api/routes/public/hitl.py 
b/airflow-core/src/airflow/api_fastapi/core_api/routes/public/hitl.py
index 2ad11a245d6..ccb2c3dd77f 100644
--- a/airflow-core/src/airflow/api_fastapi/core_api/routes/public/hitl.py
+++ b/airflow-core/src/airflow/api_fastapi/core_api/routes/public/hitl.py
@@ -243,8 +243,6 @@ def update_hitl_detail(
             task_instance=locked_ti,
             session=session,
         )
-
-    session.commit()
     return HITLDetailResponse.model_validate(hitl_detail_model)
 
 
diff --git a/airflow-core/src/airflow/api_fastapi/execution_api/routes/hitl.py 
b/airflow-core/src/airflow/api_fastapi/execution_api/routes/hitl.py
index 802b09502e0..74cda44efe7 100644
--- a/airflow-core/src/airflow/api_fastapi/execution_api/routes/hitl.py
+++ b/airflow-core/src/airflow/api_fastapi/execution_api/routes/hitl.py
@@ -131,7 +131,6 @@ def update_hitl_detail(
     hitl_detail_model.chosen_options = payload.chosen_options
     hitl_detail_model.params_input = payload.params_input
     session.add(hitl_detail_model)
-    session.commit()
     return HITLDetailResponse.from_hitl_detail_orm(hitl_detail_model)
 
 
diff --git a/airflow-core/src/airflow/api_fastapi/execution_api/routes/xcoms.py 
b/airflow-core/src/airflow/api_fastapi/execution_api/routes/xcoms.py
index 9ab8eb20071..0cb6ccb23ce 100644
--- a/airflow-core/src/airflow/api_fastapi/execution_api/routes/xcoms.py
+++ b/airflow-core/src/airflow/api_fastapi/execution_api/routes/xcoms.py
@@ -481,5 +481,4 @@ def delete_xcom(
         XComModel.map_index == map_index,
     )
     session.execute(query)
-    session.commit()
     return {"message": f"XCom with key: {key} successfully deleted."}

Reply via email to