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

View File

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