fix: deal with undefined valueType (#6684)

* fix: deal with undefined valueType

* fix

* fix

* fix key
This commit is contained in:
gaga0714
2026-03-31 16:56:32 +08:00
committed by GitHub
parent b884631363
commit c5371ae886
4 changed files with 20 additions and 9 deletions

View File

@@ -232,6 +232,16 @@ export const FlowValueTypeMap: Record<
}
};
export const getFlowValueTypeMeta = (
valueType?: WorkflowIOValueTypeEnum | string | null
): (typeof FlowValueTypeMap)[WorkflowIOValueTypeEnum] => {
if (valueType == null || valueType === '') {
return FlowValueTypeMap[WorkflowIOValueTypeEnum.any];
}
const meta = FlowValueTypeMap[valueType as WorkflowIOValueTypeEnum];
return meta ?? FlowValueTypeMap[WorkflowIOValueTypeEnum.any];
};
export const EDGE_TYPE = 'default';
export const chatHistoryValueDesc = `{

View File

@@ -14,7 +14,7 @@ import MyIconButton from '@fastgpt/web/components/common/Icon/button';
import { useToast } from '@fastgpt/web/hooks/useToast';
import {
FlowNodeInputTypeEnum,
FlowValueTypeMap
getFlowValueTypeMeta
} from '@fastgpt/global/core/workflow/node/constant';
import { WorkflowIOValueTypeEnum } from '@fastgpt/global/core/workflow/constants';
import { useMemoEnhance } from '@fastgpt/web/hooks/useMemoEnhance';
@@ -255,7 +255,7 @@ const Reference = ({
fontSize={'sm'}
fontWeight={'medium'}
>
{t(FlowValueTypeMap[inputChildren.valueType || WorkflowIOValueTypeEnum.any].label)}
{t(getFlowValueTypeMeta(inputChildren.valueType).label)}
</Flex>
</Flex>
{!isEmptyItem && (

View File

@@ -3,7 +3,7 @@ import type { FlowNodeOutputItemType } from '@fastgpt/global/core/workflow/type/
import { Box, Flex, Input, HStack } from '@chakra-ui/react';
import {
FlowNodeOutputTypeEnum,
FlowValueTypeMap
getFlowValueTypeMeta
} from '@fastgpt/global/core/workflow/node/constant';
import { WorkflowIOValueTypeEnum } from '@fastgpt/global/core/workflow/constants';
import { useTranslation } from 'next-i18next';
@@ -90,7 +90,7 @@ const DynamicOutputs = ({ nodeId, outputs, addOutput }: DynamicOutputsProps) =>
{outputs.length > 0 && <Box w={6} />}
</Flex>
{[...outputs, defaultOutput].map((output, index) => (
<Box key={output.key} _notLast={{ mb: 1.5 }}>
<Box key={output.key || index} _notLast={{ mb: 1.5 }}>
<DynamicOutputItem
output={output}
outputs={outputs}
@@ -135,7 +135,7 @@ const DynamicOutputItem = ({
type !== WorkflowIOValueTypeEnum.selectApp && type !== WorkflowIOValueTypeEnum.dynamic
)
.map((item) => ({
label: t(FlowValueTypeMap[item].label),
label: t(getFlowValueTypeMeta(item).label),
value: item
}));
}, [t]);
@@ -178,6 +178,8 @@ const DynamicOutputItem = ({
[output, onUpdate, onAdd, isEmptyItem, outputs]
);
const selectValueType = getFlowValueTypeMeta(output?.valueType).value;
return (
<Flex alignItems={'center'} mb={1} gap={2}>
<Flex flex={'1'} bg={'white'} rounded={'md'}>
@@ -198,7 +200,7 @@ const DynamicOutputItem = ({
h={10}
borderLeftRadius={'none'}
borderColor={'myGray.200'}
value={output?.valueType}
value={selectValueType}
list={valueTypeList}
onChange={onChangeValueType}
isDisabled={isEmptyItem}

View File

@@ -1,4 +1,4 @@
import { FlowValueTypeMap } from '@fastgpt/global/core/workflow/node/constant';
import { getFlowValueTypeMeta } from '@fastgpt/global/core/workflow/node/constant';
import type { BoxProps } from '@chakra-ui/react';
import { Box } from '@chakra-ui/react';
import type { WorkflowIOValueTypeEnum } from '@fastgpt/global/core/workflow/constants';
@@ -14,9 +14,8 @@ const ValueTypeLabel = ({
valueType?: WorkflowIOValueTypeEnum;
valueDesc?: string;
} & BoxProps) => {
const valueTypeData = valueType ? FlowValueTypeMap[valueType] : undefined;
const { t } = useTranslation();
const label = valueTypeData?.label || '';
const label = valueType ? getFlowValueTypeMeta(valueType).label : '';
return !!label ? (
<MyTooltip label={valueDesc}>