Skip to content

Commit d80608c

Browse files
committed
Fix
1 parent 6f66d33 commit d80608c

File tree

2 files changed

+55
-3
lines changed

2 files changed

+55
-3
lines changed

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/hooks/use-workflow-execution.ts

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
TriggerUtils,
1616
} from '@/lib/workflows/triggers/triggers'
1717
import { useCurrentWorkflow } from '@/app/workspace/[workspaceId]/w/[workflowId]/hooks/use-current-workflow'
18+
import { getBlock } from '@/blocks'
1819
import type { SerializableExecutionState } from '@/executor/execution/types'
1920
import type { BlockLog, BlockState, ExecutionResult, StreamingExecution } from '@/executor/types'
2021
import { hasExecutionResult } from '@/executor/utils/errors'
@@ -1477,8 +1478,29 @@ export function useWorkflowExecution() {
14771478
const candidates = resolveStartCandidates(mergedStates, { execution: 'manual' })
14781479
const candidate = candidates.find((c) => c.blockId === blockId)
14791480

1481+
logger.info('Run-from-block trigger analysis', {
1482+
blockId,
1483+
blockType: workflowBlocks[blockId]?.type,
1484+
blockTriggerMode: workflowBlocks[blockId]?.triggerMode,
1485+
candidateFound: !!candidate,
1486+
candidatePath: candidate?.path,
1487+
allCandidates: candidates.map((c) => ({
1488+
blockId: c.blockId,
1489+
type: c.block.type,
1490+
path: c.path,
1491+
})),
1492+
})
1493+
14801494
if (candidate) {
1481-
if (triggerNeedsMockPayload(candidate)) {
1495+
const needsMockPayload = triggerNeedsMockPayload(candidate)
1496+
logger.info('Trigger mock payload check', {
1497+
needsMockPayload,
1498+
path: candidate.path,
1499+
isExternalTrigger: candidate.path === StartBlockPath.EXTERNAL_TRIGGER,
1500+
blockType: candidate.block.type,
1501+
})
1502+
1503+
if (needsMockPayload) {
14821504
workflowInput = extractTriggerMockPayload(candidate)
14831505
logger.info('Extracted mock payload for trigger block', { blockId, workflowInput })
14841506
} else if (
@@ -1500,6 +1522,32 @@ export function useWorkflowExecution() {
15001522
}
15011523
}
15021524
}
1525+
} else {
1526+
// Fallback for trigger blocks not found in candidates
1527+
// This can happen when the block is a trigger by position (no incoming edges)
1528+
// but wasn't classified as a start candidate (e.g., triggerMode not set)
1529+
const block = mergedStates[blockId]
1530+
if (block) {
1531+
const blockConfig = getBlock(block.type)
1532+
const hasTriggers = blockConfig?.triggers?.available?.length
1533+
1534+
if (hasTriggers || block.triggerMode) {
1535+
// Block has trigger capability - extract mock payload
1536+
const syntheticCandidate = {
1537+
blockId,
1538+
block,
1539+
path: StartBlockPath.EXTERNAL_TRIGGER,
1540+
}
1541+
workflowInput = extractTriggerMockPayload(syntheticCandidate)
1542+
logger.info('Extracted mock payload for trigger block (fallback)', {
1543+
blockId,
1544+
blockType: block.type,
1545+
hasTriggers,
1546+
triggerMode: block.triggerMode,
1547+
workflowInput,
1548+
})
1549+
}
1550+
}
15031551
}
15041552
}
15051553

apps/sim/executor/execution/executor.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ export class DAGExecutor {
107107
startBlockId: string,
108108
sourceSnapshot: SerializableExecutionState
109109
): Promise<ExecutionResult> {
110-
const dag = this.dagBuilder.build(this.workflow)
110+
// Pass startBlockId as trigger so DAG includes it and all downstream blocks
111+
const dag = this.dagBuilder.build(this.workflow, startBlockId)
111112

112113
const executedBlocks = new Set(sourceSnapshot.executedBlocks)
113114
const validation = validateRunFromBlock(startBlockId, dag, executedBlocks)
@@ -297,7 +298,10 @@ export class DAGExecutor {
297298
skipStarterBlockInit: true,
298299
})
299300
} else if (overrides?.runFromBlockContext) {
300-
logger.info('Run-from-block mode: skipping starter block initialization', {
301+
// In run-from-block mode, still initialize the start block with workflow input
302+
// This ensures trigger blocks get their mock payload
303+
this.initializeStarterBlock(context, state, overrides.runFromBlockContext.startBlockId)
304+
logger.info('Run-from-block mode: initialized start block', {
301305
startBlockId: overrides.runFromBlockContext.startBlockId,
302306
})
303307
} else {

0 commit comments

Comments
 (0)