feat(core): Don't store insights for sub workflow executions (#14384)

This commit is contained in:
Danny Martini
2025-04-03 15:16:50 +02:00
committed by GitHub
parent 328976e5fe
commit 7379f44896
2 changed files with 28 additions and 24 deletions

View File

@@ -153,30 +153,31 @@ describe('workflowExecuteAfterHandler', () => {
expect(allInsights).toHaveLength(0); expect(allInsights).toHaveLength(0);
}); });
test.each<{ mode: WorkflowExecuteMode }>([{ mode: 'internal' }, { mode: 'manual' }])( test.each<{ mode: WorkflowExecuteMode }>([
'does not store events for executions with the mode `$mode`', { mode: 'internal' },
async ({ mode }) => { { mode: 'manual' },
// ARRANGE { mode: 'integrated' },
const ctx = mock<ExecutionLifecycleHooks>({ workflowData: workflow }); ])('does not store events for executions with the mode `$mode`', async ({ mode }) => {
const startedAt = DateTime.utc(); // ARRANGE
const stoppedAt = startedAt.plus({ seconds: 5 }); const ctx = mock<ExecutionLifecycleHooks>({ workflowData: workflow });
const run = mock<IRun>({ const startedAt = DateTime.utc();
mode, const stoppedAt = startedAt.plus({ seconds: 5 });
status: 'success', const run = mock<IRun>({
startedAt: startedAt.toJSDate(), mode,
stoppedAt: stoppedAt.toJSDate(), status: 'success',
}); startedAt: startedAt.toJSDate(),
stoppedAt: stoppedAt.toJSDate(),
});
// ACT // ACT
await insightsService.workflowExecuteAfterHandler(ctx, run); await insightsService.workflowExecuteAfterHandler(ctx, run);
// ASSERT // ASSERT
const metadata = await insightsMetadataRepository.findOneBy({ workflowId: workflow.id }); const metadata = await insightsMetadataRepository.findOneBy({ workflowId: workflow.id });
const allInsights = await insightsRawRepository.find(); const allInsights = await insightsRawRepository.find();
expect(metadata).toBeNull(); expect(metadata).toBeNull();
expect(allInsights).toHaveLength(0); expect(allInsights).toHaveLength(0);
}, });
);
test.each<{ mode: WorkflowExecuteMode }>([ test.each<{ mode: WorkflowExecuteMode }>([
{ mode: 'evaluation' }, { mode: 'evaluation' },
@@ -185,7 +186,6 @@ describe('workflowExecuteAfterHandler', () => {
{ mode: 'retry' }, { mode: 'retry' },
{ mode: 'trigger' }, { mode: 'trigger' },
{ mode: 'webhook' }, { mode: 'webhook' },
{ mode: 'integrated' },
])('stores events for executions with the mode `$mode`', async ({ mode }) => { ])('stores events for executions with the mode `$mode`', async ({ mode }) => {
// ARRANGE // ARRANGE
const ctx = mock<ExecutionLifecycleHooks>({ workflowData: workflow }); const ctx = mock<ExecutionLifecycleHooks>({ workflowData: workflow });

View File

@@ -37,13 +37,17 @@ const shouldSkipStatus: Record<ExecutionStatus, boolean> = {
const shouldSkipMode: Record<WorkflowExecuteMode, boolean> = { const shouldSkipMode: Record<WorkflowExecuteMode, boolean> = {
cli: false, cli: false,
error: false, error: false,
integrated: false,
retry: false, retry: false,
trigger: false, trigger: false,
webhook: false, webhook: false,
evaluation: false, evaluation: false,
// sub workflows
integrated: true,
// error workflows
internal: true, internal: true,
manual: true, manual: true,
}; };