From fc284aba85fb8ea06077581f4281449159afd4e6 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 26 Jan 2026 12:07:52 -0500 Subject: [PATCH] fix: disable incremental sync for Companies and Resources Companies and Resources entities in Autotask API do not support date-based filtering for incremental syncs. When attempting incremental sync, Autotask returns errors: - Companies: 'Unable to find lastTrackedModificationDateTime' - Resources: 'Unable to find lastModifiedDate' Solution: - Skip incremental sync for these entities - Always perform full sync for Companies and Resources - Log informational message when falling back to full sync - Other entities continue to support incremental sync normally This prevents sync failures while maintaining data freshness for Companies and Resources through full syncs. --- lib/services/entity-sync.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/services/entity-sync.ts b/lib/services/entity-sync.ts index 2fd77a8..13c371e 100644 --- a/lib/services/entity-sync.ts +++ b/lib/services/entity-sync.ts @@ -85,7 +85,10 @@ export class EntitySyncService { let params: any = {}; // For incremental sync, filter by last sync time - if (isIncremental) { + // Note: Companies and Resources don't support date-based filtering in Autotask API + const supportsIncremental = entity !== EntityType.COMPANIES && entity !== EntityType.RESOURCES; + + if (isIncremental && supportsIncremental) { try { const lastSyncTime = await getLastSyncTime(entity); if (lastSyncTime) { @@ -99,6 +102,8 @@ export class EntitySyncService { entityLogger.error('Failed to get last sync time', {}, err); throw new Error(`Failed to determine sync time: ${err.message}`); } + } else if (isIncremental && !supportsIncremental) { + entityLogger.info(`${entity} does not support incremental sync, performing full sync instead`); } else { // For full sync, build filters const filters: Array<{ field: string; op: string; value: any }> = [];