fix: Workflow Start node optional enum parameter is treated as required (#30287)

This commit is contained in:
非法操作 2025-12-29 10:02:40 +08:00 committed by GitHub
parent 1e86535c4a
commit 44ab8a3376
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -47,6 +47,12 @@ const getCheckboxDefaultSelectValue = (value: InputVar['default']) => {
const parseCheckboxSelectValue = (value: string) => const parseCheckboxSelectValue = (value: string) =>
value === CHECKBOX_DEFAULT_TRUE_VALUE value === CHECKBOX_DEFAULT_TRUE_VALUE
const normalizeSelectDefaultValue = (inputVar: InputVar) => {
if (inputVar.type === InputVarType.select && inputVar.default === '')
return { ...inputVar, default: undefined }
return inputVar
}
export type IConfigModalProps = { export type IConfigModalProps = {
isCreate?: boolean isCreate?: boolean
payload?: InputVar payload?: InputVar
@ -67,7 +73,7 @@ const ConfigModal: FC<IConfigModalProps> = ({
}) => { }) => {
const { modelConfig } = useContext(ConfigContext) const { modelConfig } = useContext(ConfigContext)
const { t } = useTranslation() const { t } = useTranslation()
const [tempPayload, setTempPayload] = useState<InputVar>(() => payload || getNewVarInWorkflow('') as any) const [tempPayload, setTempPayload] = useState<InputVar>(() => normalizeSelectDefaultValue(payload || getNewVarInWorkflow('') as any))
const { type, label, variable, options, max_length } = tempPayload const { type, label, variable, options, max_length } = tempPayload
const modalRef = useRef<HTMLDivElement>(null) const modalRef = useRef<HTMLDivElement>(null)
const appDetail = useAppStore(state => state.appDetail) const appDetail = useAppStore(state => state.appDetail)
@ -182,6 +188,8 @@ const ConfigModal: FC<IConfigModalProps> = ({
const newPayload = produce(tempPayload, (draft) => { const newPayload = produce(tempPayload, (draft) => {
draft.type = type draft.type = type
if (type === InputVarType.select)
draft.default = undefined
if ([InputVarType.singleFile, InputVarType.multiFiles].includes(type)) { if ([InputVarType.singleFile, InputVarType.multiFiles].includes(type)) {
(Object.keys(DEFAULT_FILE_UPLOAD_SETTING)).forEach((key) => { (Object.keys(DEFAULT_FILE_UPLOAD_SETTING)).forEach((key) => {
if (key !== 'max_length') if (key !== 'max_length')