@@ -15,6 +15,7 @@ import { InternalFlowiseError } from '../../errors/internalFlowiseError'
1515import { getErrorMessage } from '../../errors/utils'
1616import documentStoreService from '../../services/documentstore'
1717import { constructGraphs , getAppVersion , getEndingNodes , getTelemetryFlowObj , isFlowValidForStream } from '../../utils'
18+ import { sanitizeAllowedUploadMimeTypesFromConfig } from '../../utils/fileValidation'
1819import { containsBase64File , updateFlowDataWithFilePaths } from '../../utils/fileRepository'
1920import { getRunningExpressApp } from '../../utils/getRunningExpressApp'
2021import { utilGetUploadsConfig } from '../../utils/getUploadsConfig'
@@ -351,6 +352,21 @@ const updateChatflow = async (
351352 } else {
352353 updateChatFlow . type = chatflow . type
353354 }
355+ if ( updateChatFlow . chatbotConfig ) {
356+ try {
357+ const parsed = JSON . parse ( updateChatFlow . chatbotConfig ) as ICommonObject
358+ if ( parsed ?. fullFileUpload ?. allowedUploadFileTypes !== undefined ) {
359+ const current = parsed . fullFileUpload . allowedUploadFileTypes
360+ const sanitized = sanitizeAllowedUploadMimeTypesFromConfig (
361+ typeof current === 'string' ? current : String ( current ?? '' )
362+ )
363+ parsed . fullFileUpload . allowedUploadFileTypes = sanitized
364+ updateChatFlow . chatbotConfig = JSON . stringify ( parsed )
365+ }
366+ } catch {
367+ // If parsing fails, leave chatbotConfig unchanged
368+ }
369+ }
354370 const newDbChatflow = appServer . AppDataSource . getRepository ( ChatFlow ) . merge ( chatflow , updateChatFlow )
355371 await _checkAndUpdateDocumentStoreUsage ( newDbChatflow , chatflow . workspaceId )
356372 const dbResponse = await appServer . AppDataSource . getRepository ( ChatFlow ) . save ( newDbChatflow )
0 commit comments