fix: TypeError: outputParameters is not iterable (#29833)

This commit is contained in:
crazywoola
2025-12-18 11:21:12 +08:00
committed by GitHub
parent acbeb04edc
commit c086aa107c
3 changed files with 79 additions and 1 deletions

View File

@@ -0,0 +1,28 @@
import type { WorkflowToolProviderOutputParameter, WorkflowToolProviderOutputSchema } from '../types'
import { VarType } from '@/app/components/workflow/types'
const validVarTypes = new Set<string>(Object.values(VarType))
const normalizeVarType = (type?: string): VarType | undefined => {
if (!type)
return undefined
return validVarTypes.has(type) ? type as VarType : undefined
}
export const buildWorkflowOutputParameters = (
outputParameters: WorkflowToolProviderOutputParameter[] | null | undefined,
outputSchema?: WorkflowToolProviderOutputSchema | null,
): WorkflowToolProviderOutputParameter[] => {
if (Array.isArray(outputParameters))
return outputParameters
if (!outputSchema?.properties)
return []
return Object.entries(outputSchema.properties).map(([name, schema]) => ({
name,
description: schema.description,
type: normalizeVarType(schema.type),
}))
}