From 7e008cf99cc724a1d007d5125b5cd68eb3f54b4b Mon Sep 17 00:00:00 2001 From: Carina Ursu Date: Tue, 18 Apr 2023 19:56:55 -0700 Subject: [PATCH] chore: fix crash (#746) Signed-off-by: Carina Ursu --- packages/console/src/components/hooks/utils.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/console/src/components/hooks/utils.ts b/packages/console/src/components/hooks/utils.ts index b4551a321..0a786f802 100644 --- a/packages/console/src/components/hooks/utils.ts +++ b/packages/console/src/components/hooks/utils.ts @@ -16,7 +16,7 @@ export function extractCompiledNodes( return subWorkflows.reduce((out, subWorkflow) => { return [...out, ...subWorkflow.template.nodes]; - }, primary?.template?.nodes); + }, primary?.template?.nodes || []); } export function extractTaskTemplates(workflow: Workflow): TaskTemplate[] { @@ -32,10 +32,11 @@ export function extractAndIdentifyNodes( if (!workflow.closure || !workflow.closure.compiledWorkflow) { return []; } - const { primary, subWorkflows = [] } = workflow.closure.compiledWorkflow; + const { primary = {} as CompiledWorkflow, subWorkflows = [] } = + workflow.closure.compiledWorkflow; const nodes = subWorkflows.reduce( (out, subWorkflow) => [...out, ...subWorkflow.template.nodes], - primary.template.nodes, + primary?.template?.nodes || [], ); return nodes.map(node => ({