fix(knowledge): purge trashed Google Sheets tabs on a normal sync#5883
Conversation
Trashing a spreadsheet made listDocuments return an empty listing, but the sync engine's zero-document guard skips deletion reconciliation whenever a listing comes back empty and documents already exist — it can't tell a genuinely empty source apart from a provider outage. For a single-spreadsheet connector, trashing its one source item empties the entire listing, so the guard always fired and the stale tabs never got cleaned up on a normal sync, contradicting the documented behavior. Add shouldSkipEmptyListing, mirroring shouldReconcileDeletions: a connector can now set syncContext.sourceConfirmedEmpty when it has positively confirmed the empty result against the source (not merely inferred it from an empty listing page), letting reconciliation proceed. The Google Sheets connector sets this flag when it confirms the spreadsheet is trashed via a direct Drive metadata lookup. No other connector sets it, so this doesn't change behavior anywhere else.
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryMedium Risk Overview Connectors can set Reviewed by Cursor Bugbot for commit 147572d. Configure here. |
Greptile SummaryThis PR purges indexed Google Sheets tabs during a normal sync after the source spreadsheet is trashed. The main changes are:
Confidence Score: 5/5This looks safe to merge.
Important Files Changed
Reviews (2): Last reviewed commit: "fix(knowledge): let sourceConfirmedEmpty..." | Re-trigger Greptile |
…n safety threshold The zero-document guard bypass alone wasn't enough: for a trashed spreadsheet with more than 5 tabs, reconciliation would proceed but the separate mass-deletion ratio guard (>50% deleted, >5 docs) still blocked the actual delete on a normal sync, requiring a forced full resync anyway. Extracted the ratio guard into exceedsDeletionSafetyThreshold, mirroring shouldSkipEmptyListing, so a connector's positive source confirmation bypasses both guards consistently.
|
@cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 147572d. Configure here.
Summary
shouldSkipEmptyListingtosync-engine.ts, mirroring the existingshouldReconcileDeletionshelper: a connector can setsyncContext.sourceConfirmedEmptyto vouch that it positively confirmed the empty result against the source (not merely inferred it from an empty listing page). Google Sheets sets this flag when its direct Drive metadata lookup confirms the spreadsheet is trashed.Type of Change
Testing
shouldSkipEmptyListingcovering: non-empty listing, no existing docs, forced fullSync, default skip behavior, and the newsourceConfirmedEmptyoverride (including a falsy-value case).sourceConfirmedEmptyis set only on the trashed path, and left unset on the absent/false/fail-open paths.bun run lint,tsc --noEmit, and the fullconnectors+lib/knowledge/connectorstest suites (411 tests) all pass.Checklist