@@ -237,11 +237,18 @@ export const executeFlow = async ({
237
237
files,
238
238
signal
239
239
} : 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
241
248
let overrideConfig = incomingInput . overrideConfig ?? { }
242
249
const uploads = incomingInput . uploads
243
250
const prependMessages = incomingInput . history ?? [ ]
244
- const streaming = incomingInput . streaming
251
+ const streaming = incomingInput . streaming ?? false
245
252
const userMessageDateTime = new Date ( )
246
253
const chatflowid = chatflow . id
247
254
@@ -748,13 +755,18 @@ const checkIfStreamValid = async (
748
755
nodes : IReactFlowNode [ ] ,
749
756
streaming : boolean | string | undefined
750
757
) : Promise < boolean > => {
758
+ // If streaming is undefined, set to false by default
759
+ if ( streaming === undefined ) {
760
+ streaming = false
761
+ }
762
+
751
763
// Once custom function ending node exists, flow is always unavailable to stream
752
764
const isCustomFunctionEndingNode = endingNodes . some ( ( node ) => node . data ?. outputs ?. output === 'EndingNode' )
753
765
if ( isCustomFunctionEndingNode ) return false
754
766
755
767
let isStreamValid = false
756
768
for ( const endingNode of endingNodes ) {
757
- const endingNodeData = endingNode . data
769
+ const endingNodeData = endingNode . data || { } // Ensure endingNodeData is never undefined
758
770
759
771
const isEndingNode = endingNodeData ?. outputs ?. output === 'EndingNode'
760
772
@@ -800,7 +812,7 @@ export const utilBuildChatflow = async (req: Request, isInternal: boolean = fals
800
812
const isAgentFlow = chatflow . type === 'MULTIAGENT'
801
813
const httpProtocol = req . get ( 'x-forwarded-proto' ) || req . protocol
802
814
const baseURL = `${ httpProtocol } ://${ req . get ( 'host' ) } `
803
- const incomingInput : IncomingInput = req . body
815
+ const incomingInput : IncomingInput = req . body || { } // Ensure incomingInput is never undefined
804
816
const chatId = incomingInput . chatId ?? incomingInput . overrideConfig ?. sessionId ?? uuidv4 ( )
805
817
const files = ( req . files as Express . Multer . File [ ] ) || [ ]
806
818
const abortControllerId = `${ chatflow . id } _${ chatId } `
@@ -815,7 +827,7 @@ export const utilBuildChatflow = async (req: Request, isInternal: boolean = fals
815
827
}
816
828
817
829
const executeData : IExecuteFlowParams = {
818
- incomingInput : req . body ,
830
+ incomingInput, // Use the defensively created incomingInput variable
819
831
chatflow,
820
832
chatId,
821
833
baseURL,
0 commit comments