KushagraB424 opened a new issue, #69492:
URL: https://github.com/apache/airflow/issues/69492

   ### Under which category would you file this issue?
   
   Airflow Core
   
   ### Apache Airflow version
   
   main
   
   ### What happened and how to reproduce it?
   
   **Issue Description:**
   According to Airflow's coding standards, functions receiving a `session` 
parameter should not manually call `session.commit()`. In the new FastAPI 
implementation, the database session is injected via the `SessionDep` 
dependency. This dependency leverages the `create_session` context manager, 
which automatically commits the transaction when the request completes 
successfully.
   
   Despite this, several route handlers manually call `session.commit()`, which 
is redundant and breaks composability. 
   
   **Steps to reproduce:**
   Observe explicit `session.commit()` calls in the following endpoints:
   1. `airflow/api_fastapi/execution_api/routes/xcoms.py` (in `delete_xcom`)
   2. `airflow/api_fastapi/execution_api/routes/hitl.py`
   3. `airflow/api_fastapi/core_api/routes/public/hitl.py`
   4. `airflow/api_fastapi/core_api/routes/public/backfills.py`
   
   
   ### What you think should happen instead?
   
   The explicit `session.commit()` calls at the end of these route handlers 
should be removed, allowing the `SessionDep` dependency to handle the 
transaction lifecycle as designed.
   
   
   ### Operating System
   
   Not Applicable
   
   ### Deployment
   
   None
   
   ### Apache Airflow Provider(s)
   
   _No response_
   
   ### Versions of Apache Airflow Providers
   
   Not Applicable
   
   ### Official Helm Chart version
   
   Not Applicable
   
   ### Kubernetes Version
   
   Not Applicable
   
   ### Helm Chart configuration
   
   Not Applicable
   
   ### Docker Image customizations
   
   Not Applicable
   
   ### Anything else?
   
   Not Applicable
   
   ### Are you willing to submit PR?
   
   - [x] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [x] I agree to follow this project's [Code of 
Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
   


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