chore(api): migrate mail task and OAuth data source to use Session(db…#35235
Open
jerryzai wants to merge 3 commits intolanggenius:mainfrom
Open
chore(api): migrate mail task and OAuth data source to use Session(db…#35235jerryzai wants to merge 3 commits intolanggenius:mainfrom
jerryzai wants to merge 3 commits intolanggenius:mainfrom
Conversation
Contributor
Pyrefly DiffNo changes detected. |
dd1ce03 to
a438b27
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
mail_clean_document_notify_task.py: wrap all DB operations in a singlewith Session(db.engine) as session:block so that ORM objects fetched early in the task (logs, tenants, accounts) remain live when their attributes are accessed later in the loopoauth_data_source.py: migrate each method (get_access_token,save_internal_access_token,sync_data_source) to use an explicit session; theDataSourceOauthBindingrecord is read, mutated, and committed within the same session blockFiles changed
api/schedule/mail_clean_document_notify_task.pyapi/libs/oauth_data_source.pyMotivation
Part of #24138. Both files perform multi-step read-then-write patterns that are a natural fit for pure SQLAlchemy unit-of-work sessions.
Test plan