@@ -237,11 +237,18 @@ export const executeFlow = async ({
237237 files,
238238 signal
239239} : IExecuteFlowParams ) => {
240- const question = incomingInput . question
240+ // Ensure incomingInput has all required properties with default values
241+ incomingInput = {
242+ history : [ ] ,
243+ streaming : false ,
244+ ...incomingInput
245+ }
246+
247+ const question = incomingInput . question || '' // Ensure question is never undefined
241248 let overrideConfig = incomingInput . overrideConfig ?? { }
242249 const uploads = incomingInput . uploads
243250 const prependMessages = incomingInput . history ?? [ ]
244- const streaming = incomingInput . streaming
251+ const streaming = incomingInput . streaming ?? false
245252 const userMessageDateTime = new Date ( )
246253 const chatflowid = chatflow . id
247254
@@ -748,13 +755,18 @@ const checkIfStreamValid = async (
748755 nodes : IReactFlowNode [ ] ,
749756 streaming : boolean | string | undefined
750757) : Promise < boolean > => {
758+ // If streaming is undefined, set to false by default
759+ if ( streaming === undefined ) {
760+ streaming = false
761+ }
762+
751763 // Once custom function ending node exists, flow is always unavailable to stream
752764 const isCustomFunctionEndingNode = endingNodes . some ( ( node ) => node . data ?. outputs ?. output === 'EndingNode' )
753765 if ( isCustomFunctionEndingNode ) return false
754766
755767 let isStreamValid = false
756768 for ( const endingNode of endingNodes ) {
757- const endingNodeData = endingNode . data
769+ const endingNodeData = endingNode . data || { } // Ensure endingNodeData is never undefined
758770
759771 const isEndingNode = endingNodeData ?. outputs ?. output === 'EndingNode'
760772
@@ -800,7 +812,7 @@ export const utilBuildChatflow = async (req: Request, isInternal: boolean = fals
800812 const isAgentFlow = chatflow . type === 'MULTIAGENT'
801813 const httpProtocol = req . get ( 'x-forwarded-proto' ) || req . protocol
802814 const baseURL = `${ httpProtocol } ://${ req . get ( 'host' ) } `
803- const incomingInput : IncomingInput = req . body
815+ const incomingInput : IncomingInput = req . body || { } // Ensure incomingInput is never undefined
804816 const chatId = incomingInput . chatId ?? incomingInput . overrideConfig ?. sessionId ?? uuidv4 ( )
805817 const files = ( req . files as Express . Multer . File [ ] ) || [ ]
806818 const abortControllerId = `${ chatflow . id } _${ chatId } `
@@ -815,7 +827,7 @@ export const utilBuildChatflow = async (req: Request, isInternal: boolean = fals
815827 }
816828
817829 const executeData : IExecuteFlowParams = {
818- incomingInput : req . body ,
830+ incomingInput, // Use the defensively created incomingInput variable
819831 chatflow,
820832 chatId,
821833 baseURL,
0 commit comments