Skip to content

Commit 25f8c71

Browse files
fix(tables): resolve canonical workflow starts
1 parent 65e8d12 commit 25f8c71

2 files changed

Lines changed: 27 additions & 12 deletions

File tree

‎apps/sim/background/workflow-column-execution.test.ts‎

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,14 @@ const QUEUED_PAYLOAD = {
5757
},
5858
}
5959

60-
function latestDeployment(): Parameters<typeof assertWorkflowGroupMatchesLatestDeployment>[1] {
60+
function latestDeployment(
61+
startType = 'start_trigger'
62+
): Parameters<typeof assertWorkflowGroupMatchesLatestDeployment>[1] {
6163
return {
6264
blocks: {
6365
start: {
6466
id: 'start',
65-
type: 'start_trigger',
67+
type: startType,
6668
subBlocks: {
6769
inputFormat: { value: [{ name: 'company', type: 'string' }] },
6870
},
@@ -109,6 +111,20 @@ describe('latest table workflow deployment mappings', () => {
109111
).not.toThrow()
110112
})
111113

114+
it('accepts a canonical split manual start block', () => {
115+
expect(() =>
116+
assertWorkflowGroupMatchesLatestDeployment(
117+
{
118+
id: 'group-1',
119+
workflowId: 'workflow-1',
120+
outputs: [{ blockId: 'agent', path: 'content', columnName: 'column-output' }],
121+
inputMappings: [{ inputName: 'company', columnName: 'column-company' }],
122+
},
123+
latestDeployment('manual_trigger')
124+
)
125+
).not.toThrow()
126+
})
127+
112128
it('rejects an output mapping removed by the latest active deployment', () => {
113129
expect(() =>
114130
assertWorkflowGroupMatchesLatestDeployment(

‎apps/sim/background/workflow-column-execution.ts‎

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ import {
5757
import { flattenWorkflowOutputs } from '@/lib/workflows/blocks/flatten-outputs'
5858
import { normalizeInputFormatValue } from '@/lib/workflows/input-format'
5959
import type { DeployedWorkflowData } from '@/lib/workflows/persistence/utils'
60+
import { TriggerUtils } from '@/lib/workflows/triggers/triggers'
6061
import { ResolvedSecretTraceRegistry } from '@/executor/utils/resolved-secret-trace-registry'
6162

6263
export type { WorkflowGroupCellPayload }
@@ -85,15 +86,15 @@ export function assertWorkflowGroupMatchesLatestDeployment(
8586
)
8687
}
8788

88-
const startBlock = Object.values(deployment.blocks).find(
89-
(block) => block.type === 'start_trigger'
90-
)
91-
if (!startBlock) {
89+
const startCandidate = TriggerUtils.findStartBlock(deployment.blocks, 'manual')
90+
if (!startCandidate) {
9291
throw new Error('Workflow is missing a Start trigger')
9392
}
9493

9594
const validInputNames = new Set(
96-
normalizeInputFormatValue(startBlock.subBlocks?.inputFormat?.value).map((input) => input.name)
95+
normalizeInputFormatValue(startCandidate.block.subBlocks?.inputFormat?.value).map(
96+
(input) => input.name
97+
)
9798
)
9899
const invalidInput = (group.inputMappings ?? []).find(
99100
(mapping) => !validInputNames.has(mapping.inputName)
@@ -746,10 +747,8 @@ async function runWorkflowAndWriteTerminal(
746747
})
747748
return 'error'
748749
}
749-
const startBlock = normalizedData
750-
? Object.values(normalizedData.blocks).find((b) => b?.type === 'start_trigger')
751-
: undefined
752-
if (!startBlock) {
750+
const startCandidate = TriggerUtils.findStartBlock(normalizedData.blocks, 'manual')
751+
if (!startCandidate) {
753752
await writeState({
754753
status: 'error',
755754
executionId,
@@ -1037,7 +1036,7 @@ async function runWorkflowAndWriteTerminal(
10371036
},
10381037
executionMode: 'sync',
10391038
workflowTriggerType: 'table',
1040-
triggerBlockId: startBlock.id,
1039+
triggerBlockId: startCandidate.blockId,
10411040
useDraftState: false,
10421041
workflowStateOverride: normalizedData,
10431042
abortSignal: attemptSignal,

0 commit comments

Comments
 (0)