From 362db6fd2dcc8eb392637e73675c1190f59f77e2 Mon Sep 17 00:00:00 2001 From: Chuck Driesler Date: Wed, 23 Jul 2025 18:19:58 +0100 Subject: [PATCH] fix(acc): use correct automation id --- packages/server/modules/acc/index.ts | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/packages/server/modules/acc/index.ts b/packages/server/modules/acc/index.ts index 7d4bb7565..fe810c715 100644 --- a/packages/server/modules/acc/index.ts +++ b/packages/server/modules/acc/index.ts @@ -7,7 +7,10 @@ import { moduleLogger } from '@/observability/logging' import { Express } from 'express' import { db } from '@/db/knex' -import { queryAllPendingAccSyncItemsFactory } from '@/modules/acc/repositories/accSyncItems' +import { + queryAllPendingAccSyncItemsFactory, + upsertAccSyncItemFactory +} from '@/modules/acc/repositories/accSyncItems' import { scheduleExecutionFactory } from '@/modules/core/services/taskScheduler' import { acquireTaskLockFactory, @@ -18,6 +21,7 @@ import { ScheduleExecution } from '@/modules/core/domain/scheduledTasks/operatio import { AccSyncItems } from '@/modules/acc/dbSchema' import { AccSyncItem } from '@/modules/acc/domain/types' import { + getAutomationFactory, getAutomationTokenFactory, getLatestAutomationRevisionFactory, InsertableAutomationRun, @@ -215,6 +219,17 @@ const schedulePendingAccSyncItemsPoll = () => { const projectDb = await getProjectDbClient({ projectId: syncItem.projectId }) + await upsertAccSyncItemFactory({ db: projectDb })({ + ...syncItem, + status: 'SYNCING' + }) + + const automation = await getAutomationFactory({ db: projectDb })({ + automationId: syncItem.automationId + }) + + if (!automation || !automation.executionEngineAutomationId) continue + const automationRevision = await getLatestAutomationRevisionFactory({ db: projectDb })({ automationId: syncItem.automationId }) @@ -293,7 +308,7 @@ const schedulePendingAccSyncItemsPoll = () => { await triggerAutomationRun({ projectId: syncItem.projectId, - automationId: syncItem.automationId, + automationId: automation.executionEngineAutomationId, functionRuns: runData.functionRuns.map((r) => ({ ...r, runId: cryptoRandomString({ length: 15 }),