From 307f0d582790bab94a789252e04b604ff4b0a08b Mon Sep 17 00:00:00 2001 From: twwu Date: Wed, 21 Jan 2026 16:23:42 +0800 Subject: [PATCH] fix: initialize requiredInputs state to an empty object and improve requestParamsObj handling in useSingleRunFormParams hook --- .../nodes/human-input/hooks/use-single-run-form-params.ts | 7 ++----- web/eslint-suppressions.json | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/web/app/components/workflow/nodes/human-input/hooks/use-single-run-form-params.ts b/web/app/components/workflow/nodes/human-input/hooks/use-single-run-form-params.ts index d264fe9667..b3450d5e66 100644 --- a/web/app/components/workflow/nodes/human-input/hooks/use-single-run-form-params.ts +++ b/web/app/components/workflow/nodes/human-input/hooks/use-single-run-form-params.ts @@ -30,7 +30,7 @@ const useSingleRunFormParams = ({ const { inputs } = useNodeCrud(id, payload) const [showGeneratedForm, setShowGeneratedForm] = useState(false) const [formData, setFormData] = useState(null) - const [requiredInputs, setRequiredInputs] = useState>() + const [requiredInputs, setRequiredInputs] = useState>({}) const generatedInputs = useMemo(() => { const placeholderInputs = inputs.inputs.reduce((acc, input) => { if (input.placeholder.type === 'variable') { @@ -80,16 +80,13 @@ const useSingleRunFormParams = ({ const handleFetchFormContent = useCallback(async (inputs: Record) => { if (!fetchURL) return null - let requestParamsObj + let requestParamsObj: Record = {} Object.keys(inputs).forEach((key) => { if (inputs[key] === undefined) { delete inputs[key] } }) requestParamsObj = { ...inputs } - if (Object.keys(requestParamsObj).length === 0) { - requestParamsObj = undefined - } const data = await fetchHumanInputNodeStepRunForm(fetchURL, { inputs: requestParamsObj! }) setFormData(data) setRequiredInputs(requestParamsObj) diff --git a/web/eslint-suppressions.json b/web/eslint-suppressions.json index 6598c79a43..0a4c24423c 100644 --- a/web/eslint-suppressions.json +++ b/web/eslint-suppressions.json @@ -3435,7 +3435,7 @@ }, "app/components/workflow/nodes/human-input/hooks/use-single-run-form-params.ts": { "ts/no-explicit-any": { - "count": 6 + "count": 7 } }, "app/components/workflow/nodes/if-else/components/condition-list/condition-input.tsx": {