Skip to content

Remove redundant session.commit() calls in FastAPI route handlers#69495

Merged
vincbeck merged 1 commit into
apache:mainfrom
KushagraB424:fix-redundant-session-commit-fastapi
Jul 7, 2026
Merged

Remove redundant session.commit() calls in FastAPI route handlers#69495
vincbeck merged 1 commit into
apache:mainfrom
KushagraB424:fix-redundant-session-commit-fastapi

Conversation

@KushagraB424

Copy link
Copy Markdown
Contributor

Description

The database session in the FastAPI layer is injected via the SessionDep dependency, which is backed by the create_session context manager. This context manager 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 these specific route handlers in line with the codebase guideline that prohibits functions accepting a session parameter from calling commit.

Impacted Files

  • airflow/api_fastapi/execution_api/routes/xcoms.py
  • airflow/api_fastapi/execution_api/routes/hitl.py
  • airflow/api_fastapi/core_api/routes/public/hitl.py
  • airflow/api_fastapi/core_api/routes/public/backfills.py

Closes: #69492


Was generative AI tooling used to co-author this PR?
  • Yes (Antigravity)

Generated-by: Antigravity following the guidelines


  • Read the Pull Request Guidelines for more information. Note: commit author/co-author name and email in commits become permanently public when merged.
  • For fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
  • When adding dependency, check compliance with the ASF 3rd Party License Policy.
  • For significant user-facing changes create newsfragment: {pr_number}.significant.rst, in airflow-core/newsfragments. You can add this file in a follow-up commit after the PR is created so you know the PR number.

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.

Closes: apache#69492
@vincbeck vincbeck merged commit 5e23c6a into apache:main Jul 7, 2026
79 checks passed
@boring-cyborg

boring-cyborg Bot commented Jul 7, 2026

Copy link
Copy Markdown

Awesome work, congrats on your first merged pull request! You are invited to check our Issue Tracker for additional contributions.

@pierrejeambrun pierrejeambrun added the backport-to-v3-3-test Backport to v3-3-test label Jul 8, 2026
vincbeck pushed a commit that referenced this pull request Jul 8, 2026
…9495) (#69620)

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.

(cherry picked from commit 5e23c6a)

Co-authored-by: Kushagra Gupta <kushagrab424@gmail.com>
vatsrahul1001 pushed a commit that referenced this pull request Jul 9, 2026
…9495) (#69620)

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.

(cherry picked from commit 5e23c6a)

Co-authored-by: Kushagra Gupta <kushagrab424@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:API Airflow's REST/HTTP API area:task-sdk backport-to-v3-3-test Backport to v3-3-test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove redundant session.commit() calls in FastAPI route handlers

3 participants