mirror of
https://github.com/langgenius/dify.git
synced 2026-06-26 14:51:13 +08:00
fix(web): guard empty multiFiles array in getProcessedInputs
This commit is contained in:
parent
1427b0b098
commit
0dea743955
@ -92,6 +92,13 @@ describe('chat/chat/utils.ts', () => {
|
||||
expect(result.files2[0]).toHaveProperty('processed', true)
|
||||
})
|
||||
|
||||
it('handles an empty multiFiles array without throwing', () => {
|
||||
const inputs = { files1: [] }
|
||||
const inputsForm = [{ variable: 'files1', type: InputVarType.multiFiles as string }]
|
||||
const result = getProcessedInputs(inputs, inputsForm as InputForm[])
|
||||
expect(result.files1).toEqual([])
|
||||
})
|
||||
|
||||
it('processes jsonObject parsing correct json', () => {
|
||||
const inputs = {
|
||||
json1: '{"key": "value"}',
|
||||
|
||||
@ -47,7 +47,7 @@ export const getProcessedInputs = (inputs: Record<string, any>, inputsForm: Inpu
|
||||
processedInputs[item.variable] = getProcessedFiles([inputValue])[0]
|
||||
}
|
||||
else if (item.type === InputVarType.multiFiles) {
|
||||
if ('transfer_method' in inputValue[0])
|
||||
if (inputValue[0] && 'transfer_method' in inputValue[0])
|
||||
processedInputs[item.variable] = inputValue.map(processInputFileFromServer)
|
||||
else
|
||||
processedInputs[item.variable] = getProcessedFiles(inputValue)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user