Skip to content

Commit 335c015

Browse files
fix(knowledge): surface connector sync dispatch failures
1 parent d57e676 commit 335c015

2 files changed

Lines changed: 39 additions & 9 deletions

File tree

apps/sim/lib/knowledge/orchestration/connectors.test.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,33 @@ describe('performUpdateKnowledgeConnector', () => {
278278
})
279279
})
280280

281+
it('reports a queue failure after replacing an active connector source', async () => {
282+
dbChainMockFns.limit.mockResolvedValueOnce([
283+
{ id: 'conn-1', connectorType: 'notion', status: 'active' },
284+
])
285+
dbChainMockFns.returning.mockResolvedValueOnce([
286+
{ id: 'conn-1', connectorType: 'notion', status: 'active' },
287+
])
288+
mockDispatchSync.mockRejectedValueOnce(new Error('queue unavailable'))
289+
290+
const outcome = await performUpdateKnowledgeConnector({
291+
...ACTOR,
292+
knowledgeBase: KB,
293+
connectorId: 'conn-1',
294+
updates: { sourceConfig: { database: 'next' } },
295+
resolveBillingAttribution,
296+
validateSourceConfig: async () => null,
297+
})
298+
299+
expect(outcome).toMatchObject({
300+
success: false,
301+
errorCode: 'internal',
302+
error: 'queue unavailable',
303+
})
304+
expect(dbChainMockFns.update).toHaveBeenCalledOnce()
305+
expect(mockDispatchSync).toHaveBeenCalledOnce()
306+
})
307+
281308
it('saves a paused connector source without synchronizing it', async () => {
282309
dbChainMockFns.limit.mockResolvedValueOnce([
283310
{ id: 'conn-1', connectorType: 'notion', status: 'paused' },

apps/sim/lib/knowledge/orchestration/connectors.ts

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -572,16 +572,19 @@ export async function performUpdateKnowledgeConnector(
572572
}
573573

574574
if (dispatchSourceSync && billingAttribution) {
575-
dispatchSourceSync(connectorId, {
576-
billingAttribution,
577-
requestId,
578-
requireRunnable: true,
579-
}).catch((error) => {
580-
logger.error(
581-
`[${requestId}] Failed to dispatch source-change sync for connector ${connectorId}`,
582-
error
575+
try {
576+
await dispatchSourceSync(connectorId, {
577+
billingAttribution,
578+
requestId,
579+
requireRunnable: true,
580+
})
581+
} catch (error) {
582+
return classifyKnowledgeFailure(
583+
error,
584+
requestId,
585+
`Dispatch source-change sync for connector ${connectorId}`
583586
)
584-
})
587+
}
585588
}
586589

587590
return { success: true, connector: withoutSecret(updated) }

0 commit comments

Comments
 (0)