Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

fix(http): expose structured vars in HTTP body selector (#34185)

Jordan2c2cc72150af
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 00000000000..a3078464b8f
--- /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 90c230b6bb5..7e44ad5aebc 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<Props> = ({
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 00000000000..416777abfad
--- /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)
+}