FrankYang0529 opened a new pull request, #76188:
URL: https://github.com/apache/airflow/pull/76188

   ### Why
   
   - `DagBundlesManager.sync_bundles_to_db()` loads the `dag_bundle` rows, then 
creates each bundle and builds its URL template. Creating a bundle and building 
its URL template may read a connection. `GitDagBundle` reads its connection in 
its constructor. `S3DagBundle` and `WasbDagBundle` read their connection in 
`view_url_template()`.
   - When a connection lookup reaches `MetastoreBackend.get_connection`, its 
`@provide_session` wrapper calls `create_session()`. That call returns the 
scoped session that loaded the rows. `create_session()` then commits and closes 
that session, even if the lookup finds nothing. Every loaded row becomes 
detached, so later writes to `active`, `signed_url_template`, `template_params` 
and `teams` are lost with no error.
   
   ### How
   
   - Build all the templates before loading any row, so no bundle code runs 
between loading the rows and writing to those rows.
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   <!--
   If generative AI tooling has been used in the process of authoring this PR, 
please
   change below checkbox to `[X]` followed by the name of the tool, uncomment 
the "Generated-by".
   -->
   
   - [X] Yes - Claude Code
   
   <!--
   Generated-by: [Tool Name] following [the 
guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)
   -->
   
   


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