Skip to content

Commit 50182d1

Browse files
waleedlatif1claude
andcommitted
fix(connectors): set syncContext.listingCapped in all connectors with caps
OneDrive, Dropbox, SharePoint, Confluence (v2 + CQL), and Notion (3 listing functions) now set syncContext.listingCapped = true when their respective maxFiles/maxPages limit is hit. Without this, the sync engine's deletion reconciliation would run against an incomplete listing and incorrectly hard-delete documents that exist in the source but fell outside the cap window. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 6ffc0e3 commit 50182d1

File tree

5 files changed

+8
-1
lines changed

5 files changed

+8
-1
lines changed

apps/sim/connectors/confluence/confluence.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,7 @@ async function listDocumentsV2(
456456
const totalFetched = ((syncContext?.totalDocsFetched as number) ?? 0) + documents.length
457457
if (syncContext) syncContext.totalDocsFetched = totalFetched
458458
const hitLimit = maxPages > 0 && totalFetched >= maxPages
459+
if (hitLimit && syncContext) syncContext.listingCapped = true
459460

460461
return {
461462
documents,
@@ -621,6 +622,7 @@ async function listDocumentsViaCql(
621622
const totalFetched = ((syncContext?.totalDocsFetched as number) ?? 0) + documents.length
622623
if (syncContext) syncContext.totalDocsFetched = totalFetched
623624
const hitLimit = maxPages > 0 && totalFetched >= maxPages
625+
if (hitLimit && syncContext) syncContext.listingCapped = true
624626

625627
const totalSize = (data.totalSize as number) ?? 0
626628
const nextStart = start + results.length

apps/sim/connectors/dropbox/dropbox.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ export const dropboxConnector: ConnectorConfig = {
206206
const totalFetched = previouslyFetched + documents.length
207207
if (syncContext) syncContext.totalDocsFetched = totalFetched
208208
const hitLimit = maxFiles > 0 && totalFetched >= maxFiles
209+
if (hitLimit && syncContext) syncContext.listingCapped = true
209210

210211
return {
211212
documents,

apps/sim/connectors/notion/notion.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,7 @@ async function listFromWorkspace(
454454
const totalFetched = ((syncContext?.totalDocsFetched as number) ?? 0) + documents.length
455455
if (syncContext) syncContext.totalDocsFetched = totalFetched
456456
const hitLimit = maxPages > 0 && totalFetched >= maxPages
457+
if (hitLimit && syncContext) syncContext.listingCapped = true
457458

458459
const nextCursor = hitLimit ? undefined : ((data.next_cursor as string) ?? undefined)
459460

@@ -509,6 +510,7 @@ async function listFromDatabase(
509510
const totalFetched = ((syncContext?.totalDocsFetched as number) ?? 0) + documents.length
510511
if (syncContext) syncContext.totalDocsFetched = totalFetched
511512
const hitLimit = maxPages > 0 && totalFetched >= maxPages
513+
if (hitLimit && syncContext) syncContext.listingCapped = true
512514

513515
const nextCursor = hitLimit ? undefined : ((data.next_cursor as string) ?? undefined)
514516

@@ -604,6 +606,7 @@ async function listFromParentPage(
604606
const totalFetched = ((syncContext?.totalDocsFetched as number) ?? 0) + documents.length
605607
if (syncContext) syncContext.totalDocsFetched = totalFetched
606608
const hitLimit = maxPages > 0 && totalFetched >= maxPages
609+
if (hitLimit && syncContext) syncContext.listingCapped = true
607610

608611
const nextCursor = hitLimit ? undefined : ((data.next_cursor as string) ?? undefined)
609612

apps/sim/connectors/onedrive/onedrive.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ export const onedriveConnector: ConnectorConfig = {
239239
const totalFetched = previouslyFetched + documents.length
240240
if (syncContext) syncContext.totalDocsFetched = totalFetched
241241
const hitLimit = maxFiles > 0 && totalFetched >= maxFiles
242+
if (hitLimit && syncContext) syncContext.listingCapped = true
242243

243244
const nextLink = data['@odata.nextLink']
244245

apps/sim/connectors/sharepoint/sharepoint.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,8 +393,8 @@ export const sharepointConnector: ConnectorConfig = {
393393

394394
if (syncContext) syncContext.totalDocsFetched = totalFetched
395395
const hitLimit = maxFiles > 0 && totalFetched >= maxFiles
396+
if (hitLimit && syncContext) syncContext.listingCapped = true
396397

397-
// Determine next cursor
398398
if (hitLimit) {
399399
return { documents, hasMore: false }
400400
}

0 commit comments

Comments
 (0)