@@ -16,7 +16,7 @@ import { WorkflowValidationError } from '@/serializer'
1616import { useExecutionStore } from '@/stores/execution/store'
1717import { useVariablesStore } from '@/stores/panel/variables/store'
1818import { useEnvironmentStore } from '@/stores/settings/environment/store'
19- import { useTerminalConsoleStore } from '@/stores/terminal'
19+ import { type ConsoleEntry , useTerminalConsoleStore } from '@/stores/terminal'
2020import { useWorkflowDiffStore } from '@/stores/workflow-diff'
2121import { useWorkflowRegistry } from '@/stores/workflows/registry/store'
2222import { mergeSubblockState } from '@/stores/workflows/utils'
@@ -1005,21 +1005,31 @@ export function useWorkflowExecution() {
10051005 logs : [ ] ,
10061006 }
10071007
1008- // Add error to console
1009- addConsole ( {
1010- input : { } ,
1011- output : { } ,
1012- success : false ,
1013- error : data . error ,
1014- durationMs : data . duration || 0 ,
1015- startedAt : new Date ( Date . now ( ) - ( data . duration || 0 ) ) . toISOString ( ) ,
1016- endedAt : new Date ( ) . toISOString ( ) ,
1017- workflowId : activeWorkflowId ,
1018- blockId : 'workflow' ,
1019- executionId : executionId || uuidv4 ( ) ,
1020- blockName : 'Workflow Execution' ,
1021- blockType : 'workflow' ,
1022- } )
1008+ // Only add workflow-level error if no blocks have executed yet
1009+ // This catches pre-execution errors (validation, serialization, etc.)
1010+ // Block execution errors are already logged via onBlockError callback
1011+ const { entries } = useTerminalConsoleStore . getState ( )
1012+ const existingLogs = entries . filter (
1013+ ( log : ConsoleEntry ) => log . executionId === executionId
1014+ )
1015+
1016+ if ( existingLogs . length === 0 ) {
1017+ // No blocks executed yet - this is a pre-execution error
1018+ addConsole ( {
1019+ input : { } ,
1020+ output : { } ,
1021+ success : false ,
1022+ error : data . error ,
1023+ durationMs : data . duration || 0 ,
1024+ startedAt : new Date ( Date . now ( ) - ( data . duration || 0 ) ) . toISOString ( ) ,
1025+ endedAt : new Date ( ) . toISOString ( ) ,
1026+ workflowId : activeWorkflowId ,
1027+ blockId : 'validation' ,
1028+ executionId : executionId || uuidv4 ( ) ,
1029+ blockName : 'Workflow Validation' ,
1030+ blockType : 'validation' ,
1031+ } )
1032+ }
10231033 } ,
10241034 } ,
10251035 } )
0 commit comments