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.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
fix(web): resolve Dify compact array types in tool output schema (#34804)
平衡世界的BOY1befd2a602c5
diff --git a/web/app/components/workflow/nodes/tool/__tests__/output-schema-utils.spec.ts b/web/app/components/workflow/nodes/tool/__tests__/output-schema-utils.spec.tsindex 4d095ab189c..f5179742b25 100644--- a/web/app/components/workflow/nodes/tool/__tests__/output-schema-utils.spec.ts+++ b/web/app/components/workflow/nodes/tool/__tests__/output-schema-utils.spec.ts@@ -229,6 +229,23 @@ describe('output-schema-utils', () => {})})+ describe('Dify compact types (workflow-as-tool output_schema)', () => {+ it('should resolve array[string] to arrayString (issue #34428)', () => {+ const result = resolveVarType({ type: 'array[string]' })+ expect(result.type).toBe(VarType.arrayString)+ })++ it('should resolve Array[string] case-insensitively', () => {+ const result = resolveVarType({ type: 'Array[string]' })+ expect(result.type).toBe(VarType.arrayString)+ })++ it('should resolve array[object] to arrayObject', () => {+ const result = resolveVarType({ type: 'array[object]' })+ expect(result.type).toBe(VarType.arrayObject)+ })+ })+describe('unknown types', () => {it('should resolve unknown type to any', () => {const result = resolveVarType({ type: 'unknown_type' })diff --git a/web/app/components/workflow/nodes/tool/output-schema-utils.ts b/web/app/components/workflow/nodes/tool/output-schema-utils.tsindex 141c679da0d..630673e3e98 100644--- a/web/app/components/workflow/nodes/tool/output-schema-utils.ts+++ b/web/app/components/workflow/nodes/tool/output-schema-utils.ts@@ -2,6 +2,30 @@ import type { SchemaTypeDefinition } from '@/service/use-common'import { VarType } from '@/app/components/workflow/types'import { getMatchedSchemaType } from '../_base/components/variable/use-match-schema-type'+/**+ * Workflow-as-tool and some internal APIs store Dify VarType strings (e.g. `array[string]`)+ * in JSON Schema `type` instead of standard `{ type: 'array', items: { type: 'string' } }`.+ * Map those compact strings to VarType so downstream (e.g. Code node var picker) does not+ * fall back to `any` and get filtered out.+ */+const resolveDifyCompactTypeString = (typeStr: string): VarType | undefined => {+ const trimmed = typeStr.trim()+ const m = /^array\[(string|number|integer|boolean|object|file|any)\]$/i.exec(trimmed)+ if (!m)+ return undefined+ const inner = m[1].toLowerCase()+ const map: Record<string, VarType> = {+ string: VarType.arrayString,+ number: VarType.arrayNumber,+ integer: VarType.arrayNumber,+ boolean: VarType.arrayBoolean,+ object: VarType.arrayObject,+ file: VarType.arrayFile,+ any: VarType.arrayAny,+ }+ return map[inner]+}+/*** Normalizes a JSON Schema type to a simple string type.* Handles complex schemas with oneOf, anyOf, allOf.@@ -54,6 +78,12 @@ export const resolveVarType = (schemaTypeDefinitions?: SchemaTypeDefinition[],): { type: VarType, schemaType?: string } => {const schemaType = getMatchedSchemaType(schema, schemaTypeDefinitions)+ if (schema && typeof schema.type === 'string') {+ const compact = resolveDifyCompactTypeString(schema.type)+ if (compact !== undefined)+ return { type: compact, schemaType }+ }+const normalizedType = normalizeJsonSchemaType(schema)switch (normalizedType) {