fix: add replace_duplicates option for Google Drive sync#1674
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughAdds a ChangesReplace Duplicates Parameter Propagation
Sequence DiagramsequenceDiagram
participant Client as API.connector_sync / sync_all_connectors
participant ConnectorService as ConnectorService.sync_connector_files
participant LangflowService as LangflowConnectorService.sync_connector_files
participant FileProcessor as ConnectorFileProcessor / LangflowConnectorFileProcessor
Client->>ConnectorService: call (replace_duplicates=_connector_sync_should_replace(connector_type))
ConnectorService->>FileProcessor: instantiate(process file, replace_duplicates flag)
Client->>LangflowService: call (filename_filter / replace_duplicates)
LangflowService->>FileProcessor: instantiate(process file, replace_duplicates flag)
🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/connectors/langflow_connector_service.py`:
- Around line 232-233: The function accepts filename_filter (and
replace_duplicates) but the Langflow sync path never uses filename_filter;
update the loop in the Langflow sync path that enqueues files so that if
filename_filter is not None you only enqueue files whose filename is a member of
the filename_filter set (e.g., if filename_filter and filename not in
filename_filter: continue), thereby skipping non-matching files before any
enqueue/queue logic and preserving existing replace_duplicates behavior.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 96bcd538-ae8a-492a-af34-f02b7e921097
📒 Files selected for processing (3)
src/api/connectors.pysrc/connectors/langflow_connector_service.pysrc/connectors/service.py
fix: Google Drive sync replaces existing files instead of failing
Problem
When syncing Google Drive via the UI sync button (both the connector-specific
/connectors/google_drive/syncand the global/connectors/sync-allendpoints), files that were already indexed would fail with:This happened because
ConnectorFileProcessorandLangflowConnectorFileProcessorboth gate re-ingestion behind areplace_duplicatesflag that defaults toFalse. The sync code paths were never passingreplace_duplicates=True, so every re-sync of a previously indexed file was treated as a duplicate error instead of an update.The
sync_specific_filespath (used for manual file selection) already hadreplace_duplicateswired correctly — the gap was exclusively in the background/button-triggered sync paths.Changes
src/api/connectors.py— Passreplace_duplicates=Trueforgoogle_drivein both theconnector_syncandsync_all_connectorsendpoints, covering thesync_specific_filescall (primary path when document IDs are indexed) and thesync_connector_filesfallback (filename-based path for older Langflow-ingested files).src/connectors/service.py— Addreplace_duplicates: bool = Falseparameter tosync_connector_filesand thread it through toConnectorFileProcessor.src/connectors/langflow_connector_service.py— Addfilename_filterandreplace_duplicatesparameters tosync_connector_files(both were missing, causing a latentTypeErroron the fallback path) and threadreplace_duplicatesthrough toLangflowConnectorFileProcessor.Scope
Only Google Drive sync behavior changes. All other connectors continue to receive
replace_duplicates=False(the existing default). Manual file uploads via the UI are unaffected — those processors are instantiated separately and theirreplace_duplicatesflag remains user-controlled.Test plan
indexedorunchanged, noalready existserrorsunchanged(hash deduplication still applies)pytest tests/unit/ -k connectorSummary by CodeRabbit