Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(designer): Stringified Integers are not handled in switch cases and are casted to integers #4568

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,7 @@ export const TokenField = ({
placeholder={placeholder}
readonly={readOnly}
initialValue={value}
options={dropdownOptions.map((option: any, index: number) => ({
key: index.toString(),
...option,
displayName: typeof option.displayName === 'string' ? option.displayName : JSON.stringify(option.displayName),
}))}
options={dropdownOptions.map((option: any, index: number) => ({ key: index.toString(), ...option }))}
useOption={true}
isLoading={isLoading}
errorDetails={errorDetails}
Expand Down
6 changes: 4 additions & 2 deletions libs/designer/src/lib/core/actions/bjsworkflow/initialize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ export const getInputParametersFromManifest = (
manifest: OperationManifest,
presetParameterValues?: Record<string, any>,
customSwagger?: SwaggerParser,
stepDefinition?: any
stepDefinition?: any,
suppressTypeConversion?: boolean
): NodeInputsWithDependencies => {
const primaryInputParameters = new ManifestParser(manifest).getInputParameters(
false /* includeParentObject */,
Expand Down Expand Up @@ -145,7 +146,8 @@ export const getInputParametersFromManifest = (
manifest,
customSwagger,
operationData,
primaryInputParametersInArray
primaryInputParametersInArray,
suppressTypeConversion
),
'',
primaryInputParametersInArray,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import type { CustomCodeFileNameMapping } from '../../..';
import Constants from '../../../common/constants';
import type { ConnectionReference, ConnectionReferences, WorkflowParameter } from '../../../common/models/workflow';
import type { DeserializedWorkflow } from '../../parsers/BJSWorkflow/BJSDeserializer';
import { isSwitchAction, type DeserializedWorkflow } from '../../parsers/BJSWorkflow/BJSDeserializer';
import type { WorkflowNode } from '../../parsers/models/workflowNode';
import type { ConnectorWithParsedSwagger } from '../../queries/connections';
import { getConnectorWithSwagger } from '../../queries/connections';
Expand Down Expand Up @@ -68,6 +68,8 @@ import {
getRecordEntry,
getFileExtensionNameFromOperationId,
parseErrorMessage,
isNumber,
isStringBoolean,
} from '@microsoft/logic-apps-shared';
import type { InputParameter, OutputParameter, LogicAppsV2, OperationManifest } from '@microsoft/logic-apps-shared';
import type { Dispatch } from '@reduxjs/toolkit';
Expand Down Expand Up @@ -270,7 +272,7 @@ export const initializeOperationDetailsForManifest = async (
forceEnableSplitOn
);

const childGraphInputs = processChildGraphAndItsInputs(manifest, operation);
const childGraphInputs = processChildGraphAndItsInputs(manifest, operation, isSwitchAction(operation));

return [
{
Expand Down Expand Up @@ -303,7 +305,8 @@ export const initializeOperationDetailsForManifest = async (

const processChildGraphAndItsInputs = (
manifest: OperationManifest,
operation: LogicAppsV2.ActionDefinition | LogicAppsV2.TriggerDefinition
operation: LogicAppsV2.ActionDefinition | LogicAppsV2.TriggerDefinition,
isSwitch?: boolean
): NodeDataWithOperationMetadata[] => {
const { subGraphDetails } = manifest.properties;
const nodesData: NodeDataWithOperationMetadata[] = [];
Expand All @@ -316,12 +319,15 @@ const processChildGraphAndItsInputs = (
const subManifest = { properties: { inputs, inputsLocation } } as any;
if (isAdditive) {
for (const subNodeKey of Object.keys(subOperation)) {
const caseValue = subOperation[subNodeKey]?.case;
const suppressTypeConversion = !!isSwitch && typeof caseValue === 'string' && isNumber(caseValue);
const { inputs: subNodeInputs, dependencies: subNodeInputDependencies } = getInputParametersFromManifest(
subNodeKey,
subManifest,
/* presetParameterValues */ undefined,
/* customSwagger */ undefined,
subOperation[subNodeKey]
subOperation[subNodeKey],
suppressTypeConversion
);
const subNodeOutputs = { outputs: {} };
nodesData.push({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ const isIfAction = (action: LogicAppsV2.ActionDefinition): action is LogicAppsV2
return equals(action?.type, 'if');
};

const isSwitchAction = (action: LogicAppsV2.ActionDefinition): action is LogicAppsV2.SwitchAction => {
export const isSwitchAction = (action: LogicAppsV2.ActionDefinition): action is LogicAppsV2.SwitchAction => {
return equals(action?.type, 'switch');
};

Expand Down
11 changes: 9 additions & 2 deletions libs/designer/src/lib/core/utils/parameters/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2555,14 +2555,21 @@ export function getInputsValueFromDefinitionForManifest(
manifest: OperationManifest,
customSwagger: SwaggerParser | undefined,
stepDefinition: any,
allInputs: InputParameter[]
allInputs: InputParameter[],
suppressTypeConversion: boolean = false
): any {
let inputsValue = stepDefinition;

for (const property of inputsLocation) {
// NOTE: Currently this only supports single item array. Might need to be updated when multiple array support operations are added.
// None right now in any connectors.
inputsValue = property === '[*]' ? inputsValue[0] : getPropertyValue(inputsValue, property);
const propertyValue = getPropertyValue(inputsValue, property);
inputsValue =
property === '[*]'
? inputsValue[0]
: typeof propertyValue === 'string' && suppressTypeConversion
? `"${propertyValue}"`
: propertyValue;
}

inputsValue = swapInputsValueIfNeeded(inputsValue, manifest);
Expand Down
Loading