diff --git a/apps/sim/executor/utils/errors.ts b/apps/sim/executor/utils/errors.ts index 3144d9c71..f92c9c1ff 100644 --- a/apps/sim/executor/utils/errors.ts +++ b/apps/sim/executor/utils/errors.ts @@ -11,14 +11,20 @@ export interface ErrorWithExecutionResult extends Error { /** * Type guard to check if an error carries an ExecutionResult. + * Validates that executionResult has required fields (success, output). */ export function hasExecutionResult(error: unknown): error is ErrorWithExecutionResult { - return ( - error instanceof Error && - 'executionResult' in error && - error.executionResult != null && - typeof error.executionResult === 'object' - ) + if ( + !(error instanceof Error) || + !('executionResult' in error) || + error.executionResult == null || + typeof error.executionResult !== 'object' + ) { + return false + } + + const result = error.executionResult as Record + return typeof result.success === 'boolean' && result.output != null } /**