Repository navigation
refactor(models): remove legacy db.session property wrappers on Document - #41721
Merged
asukaminato0721 merged 2 commits intoSep 3, 2026
Conversation
keith991001
requested review from
JohnJyong,
QuantumGhost and
laipz8200
as code owners
September 3, 2026 07:01
Contributor
Pyrefly Type Coverage
|
asukaminato0721
enabled auto-merge
September 3, 2026 13:34
asukaminato0721
approved these changes
Sep 3, 2026
2 of 5 tasks
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.
Important
Summary
Part of #40372, follow-up to #41647.
Removes four
Documentlegacy@propertyaccessors inapi/models/dataset.pythat reach for the globaldb.sessioninternally — each a thin wrapper around an existing session-awareget_*twin, with no remaining property reads anywhere (response validation goes throughDocumentWithSession, and the service_api document endpoints already call theget_*twins explicitly):Document.data_source_detail_dict→get_data_source_detail_dict(session=...)Document.dataset→get_dataset(session=...)Document.uploader→get_uploader(session=...)Document.doc_metadata_details→get_doc_metadata_details(session=...)Scope note: the original claim listed seven accessors, but
Document.segment_count,hit_count, anddataset_process_ruleturned out to have intra-model consumers (Document.to_dict,average_segment_length,process_rule_dict), so removing them cleanly requires threading a session throughto_dict— a larger change than this slice. They are left untouched (and unclaimed) for a follow-up.Tests
Updated the three unit tests in
test_document_detail_api_data_source_info.pythat readdata_source_detail_dictas a property to callget_data_source_detail_dict(session=...)(these paths never touch the session, so a mock suffices). Theget_*twins keep their existing coverage intest_document_fields.py/test_dataset_models.py, all passing.Screenshots
N/A (backend-only refactor).
Checklist
make lint && make type-check(backend) andvp staged(frontend) to appease the lint godsFrom Claude Code