Uh oh!
There was an error while loading. Please reload this page.
fix(knowledge): skip sync and document processing when KB is deleted - #4327
Conversation
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryMedium Risk Overview
Reviewed by Cursor Bugbot for commit dfae79a. Configure here. |
Greptile SummaryThis PR adds defensive guards in Confidence Score: 5/5Safe to merge — no P1/P0 issues; logic is correct, type-safe, and complementary to existing scheduler-level filtering. All three change sites (dispatchSync Trigger path, executeSync, processDocumentAsync) correctly handle the deleted-KB and archived/deleted-connector cases. SyncResult.error is already typed as optional string, the scheduler already pre-filters these cases so no zombie-scheduler loop is possible, and the connector/document DB states are left in unambiguous terminal form. Previously raised review concerns have been addressed in this HEAD commit. No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
CRON["Cron scheduler\n/api/knowledge/connectors/sync"] -->|"filters: active/error, nextSyncAt≤now,\narchivedAt=null, deletedAt=null,\nkb.deletedAt=null"| DS["dispatchSync(connectorId)"]
DS -->|"isTriggerAvailable()"| TRG_PATH["Trigger.dev path"]
DS -->|"else"| INLINE["executeSync (inline, fire-and-forget)"]
TRG_PATH --> R1{"row found?"}
R1 -->|"No"| WARN1["log warn, return"]
R1 -->|"Yes"| R2{"kb deleted?"}
R2 -->|"Yes"| UPD1["set connector status=error,\nnextSyncAt=null, log warn, return"]
R2 -->|"No"| R3{"connector archived\nor deleted?"}
R3 -->|"Yes"| WARN2["log warn, return"]
R3 -->|"No"| ENQUEUE["Trigger.dev task enqueued"]
ENQUEUE --> ES["executeSync(connectorId)"]
INLINE --> ES
ES --> C1{"connector found\n(not archived/deleted)?"}
C1 -->|"No"| RET1["return {error: 'connector_unavailable'}"]
C1 -->|"Yes"| C2{"KB found\n(not deleted)?"}
C2 -->|"No"| UPD2["set connector status=error,\nnextSyncAt=null\nreturn {error: 'knowledge_base_deleted'}"]
C2 -->|"Yes"| SYNC["Run sync logic"]
PDA["processDocumentAsync"] --> KB_CHK{"KB found\n(not deleted)?"}
KB_CHK -->|"No"| DOC_FAIL["mark document failed\n'Knowledge base deleted', return"]
KB_CHK -->|"Yes"| PROC["Process document"]
Reviews (4): Last reviewed commit: "fix(knowledge): mark connector errored i..." | Re-trigger Greptile |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
waleedlatif1
commented
Apr 29, 2026
waleedlatif1
commented
Apr 29, 2026
@cursor review |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
waleedlatif1
commented
Apr 29, 2026
waleedlatif1
commented
Apr 29, 2026
@cursor review |
Uh oh!
There was an error while loading. Please reload this page.
waleedlatif1
commented
Apr 29, 2026
waleedlatif1
commented
Apr 29, 2026
@cursor review |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 19eb8a1. Configure here.
Uh oh!
There was an error while loading. Please reload this page.
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 dfae79a. Configure here.
Uh oh!
There was an error while loading. Please reload this page.

Summary
dispatchSyncto refuse enqueueing the connector-sync trigger task when the KB is deleted or the connector is archived/deletedexecuteSyncnow returns aSyncResultwitherrorinstead of throwing on missing connector / deleted KB, so the connector-sync task succeeds without 3x retriesprocessDocumentAsynclogs a warn and returns when the KB is deleted instead of throwing — stops the retry flood onknowledge-process-documentType of Change
Testing
Tested manually
Checklist