Skip to content

Commit

Permalink
fix(designer): Fix two places where undefined switch cases caused…
Browse files Browse the repository at this point in the history
… fatal errors (#4191)

* Fix issue where `subOperation` could be `undefined`

* Fix two fatal errors with `undefined` switch `cases`
  • Loading branch information
ek68794998 committed Feb 14, 2024
1 parent 4ea166b commit 4031b05
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ const processChildGraphAndItsInputs = (
if (subGraphDetails) {
for (const subGraphKey of Object.keys(subGraphDetails)) {
const { inputs, inputsLocation, isAdditive } = subGraphDetails[subGraphKey];
const subOperation = getPropertyValue(operation, subGraphKey);
const subOperation = getPropertyValue(operation, subGraphKey) ?? {};
if (inputs) {
const subManifest = { properties: { inputs, inputsLocation } } as any;
if (isAdditive) {
Expand Down
9 changes: 7 additions & 2 deletions libs/designer/src/lib/core/parsers/addNodeToWorkflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type { NodesMetadata, WorkflowState } from '../state/workflow/workflowInt
import { createWorkflowNode, createWorkflowEdge } from '../utils/graph';
import type { WorkflowEdge, WorkflowNode } from './models/workflowNode';
import { reassignEdgeSources, reassignEdgeTargets, addNewEdge, applyIsRootNode, removeEdge } from './restructuringHelpers';
import type { DiscoveryOperation, DiscoveryResultTypes, SubgraphType } from '@microsoft/utils-logic-apps';
import type { DiscoveryOperation, DiscoveryResultTypes, LogicAppsV2, SubgraphType } from '@microsoft/utils-logic-apps';
import {
removeIdTag,
SUBGRAPH_TYPES,
Expand Down Expand Up @@ -203,7 +203,12 @@ export const addSwitchCaseToWorkflow = (caseId: string, switchNode: WorkflowNode
addChildEdge(switchNode, createWorkflowEdge(`${switchNode.id}-#scope`, caseId, WORKFLOW_EDGE_TYPES.ONLY_EDGE));

// Add Case to Switch operation data
(state.operations[switchNode.id] as any).cases[caseId] = { actions: {}, case: '' };
const switchAction = state.operations[switchNode.id] as LogicAppsV2.SwitchAction;
switchAction.cases = {
...switchAction.cases,
[caseId]: { actions: {}, case: '' },
};

// Increase action count of graph
if (nodesMetadata[switchNode.id]) {
nodesMetadata[switchNode.id].actionCount = nodesMetadata[switchNode.id].actionCount ?? 0 + 1;
Expand Down

0 comments on commit 4031b05

Please sign in to comment.