fix(google_drive): sync a file shared between users only once #4902
All Vouch review confidence checks passed
Residual risk 0.25 = Change Risk (0.47) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.47 · 487 lines diff across 6 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.370
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #4902"
general
weight: 0.35
ShivamSharma43
Relates to: no issue
This is a bug I found while reading the Google Drive connector.
With domain-wide delegation enabled,
get_docsandget_docs_incrementallylist the My Drive of every user in the workspace (list_files_from_my_drive,corpora="user"). A file shared with several users is in each of their listings. To process it only once, both methods create aseen_idsset and pass it toprepare_files, which drops files that are already in it:But nothing ever adds an id to
seen_ids(it has been like this since domain-wide delegation was added in #1602), so the filter never removes anything. A file shared with N users is prepared and yielded N times in the same sync:_idfrom the existing ids after the first copy, so the other copies are queued as new documents and, with content extraction enabled, the file is downloaded and extracted again each time;The fix adds the ids of the files prepared from each page to
seen_ids, so a file is synced from the first listing it is found in.The personal drives used to be listed with no path lookup (
paths={}), and the folder paths were resolved only afterwards for the shared drives listing (list_files,corpora="allDrives"), which also returns files of the shared drives account's own My Drive and files shared with it. Such a file used to be yielded again from that listing with itspath, so keeping only the first copy would lose the path. The folder paths are therefore now resolved before the personal drives are listed and used there too, so the copy that is kept gets the samepaththat the shared drives listing would have given it. (Shared drive files themselves are not in the My Drive listings,includeItemsFromAllDrives=False.)Checklists
Pre-Review Checklist
config.yml.example)v7.13.2,v7.14.0,v8.0.0)Tests
In
tests/sources/test_google_drive.py:test_get_docs_with_domain_wide_delegation_yields_shared_file_once: two users, the first with a shared file and a file of their own, the second with the same shared file. The test checks thatget_docsyieldsshared_idandown_idonce each.The new test fails on
main(['shared_id', 'own_id', 'shared_id']) and passes with the fix. The rest oftest_google_drive.pyhas the same results before and after the change (on my Windows machine,test_get_contentfails onmaintoo because of the localbase64command).ruff checkandruff format --checkare clean, apart from the repo-wide CPY001 notice.🤖 Generated with Claude Code