From 2c2cc72150af67410426f66b491200a9b25c7ab7 Mon Sep 17 00:00:00 2001 From: Jordan Date: Tue, 31 Mar 2026 11:20:21 +0900 Subject: [PATCH] fix(http): expose structured vars in HTTP body selector (#34185) Co-authored-by: Jordan <175169034+owldev127@users.noreply.github.com> --- .../http/components/edit-body/index.spec.tsx | 30 +++++++++++++++++++ .../nodes/http/components/edit-body/index.tsx | 3 +- .../edit-body/supported-body-vars.ts | 15 ++++++++++ 3 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 web/app/components/workflow/nodes/http/components/edit-body/index.spec.tsx create mode 100644 web/app/components/workflow/nodes/http/components/edit-body/supported-body-vars.ts diff --git a/web/app/components/workflow/nodes/http/components/edit-body/index.spec.tsx b/web/app/components/workflow/nodes/http/components/edit-body/index.spec.tsx new file mode 100644 index 0000000000..a3078464b8 --- /dev/null +++ b/web/app/components/workflow/nodes/http/components/edit-body/index.spec.tsx @@ -0,0 +1,30 @@ +import { describe, expect, it } from 'vitest' +import { VarType } from '@/app/components/workflow/types' +import { + HTTP_BODY_VARIABLE_TYPES, + isSupportedHttpBodyVariable, +} from './supported-body-vars' + +describe('HTTP body variable support', () => { + it('should include structured variables in the selector', () => { + expect(HTTP_BODY_VARIABLE_TYPES).toEqual([ + VarType.string, + VarType.number, + VarType.secret, + VarType.object, + VarType.arrayNumber, + VarType.arrayString, + VarType.arrayObject, + ]) + }) + + it('should accept object and array object variables', () => { + expect(isSupportedHttpBodyVariable(VarType.object)).toBe(true) + expect(isSupportedHttpBodyVariable(VarType.arrayObject)).toBe(true) + }) + + it('should keep unsupported file variables excluded', () => { + expect(isSupportedHttpBodyVariable(VarType.file)).toBe(false) + expect(isSupportedHttpBodyVariable(VarType.arrayFile)).toBe(false) + }) +}) diff --git a/web/app/components/workflow/nodes/http/components/edit-body/index.tsx b/web/app/components/workflow/nodes/http/components/edit-body/index.tsx index 90c230b6bb..7e44ad5aeb 100644 --- a/web/app/components/workflow/nodes/http/components/edit-body/index.tsx +++ b/web/app/components/workflow/nodes/http/components/edit-body/index.tsx @@ -13,6 +13,7 @@ import VarReferencePicker from '../../../_base/components/variable/var-reference import useAvailableVarList from '../../../_base/hooks/use-available-var-list' import { BodyPayloadValueType, BodyType } from '../../types' import KeyValue from '../key-value' +import { isSupportedHttpBodyVariable } from './supported-body-vars' const UNIQUE_ID_PREFIX = 'key-value-' @@ -58,7 +59,7 @@ const EditBody: FC = ({ const { availableVars, availableNodes } = useAvailableVarList(nodeId, { onlyLeafNodeVar: false, filterVar: (varPayload: Var) => { - return [VarType.string, VarType.number, VarType.secret, VarType.arrayNumber, VarType.arrayString].includes(varPayload.type) + return isSupportedHttpBodyVariable(varPayload.type) }, }) diff --git a/web/app/components/workflow/nodes/http/components/edit-body/supported-body-vars.ts b/web/app/components/workflow/nodes/http/components/edit-body/supported-body-vars.ts new file mode 100644 index 0000000000..416777abfa --- /dev/null +++ b/web/app/components/workflow/nodes/http/components/edit-body/supported-body-vars.ts @@ -0,0 +1,15 @@ +import { VarType } from '@/app/components/workflow/types' + +export const HTTP_BODY_VARIABLE_TYPES: VarType[] = [ + VarType.string, + VarType.number, + VarType.secret, + VarType.object, + VarType.arrayNumber, + VarType.arrayString, + VarType.arrayObject, +] + +export const isSupportedHttpBodyVariable = (type: VarType) => { + return HTTP_BODY_VARIABLE_TYPES.includes(type) +}