diff --git a/packages/server/src/utils/index.ts b/packages/server/src/utils/index.ts index 2f884b11aae..9e90bbe87bc 100644 --- a/packages/server/src/utils/index.ts +++ b/packages/server/src/utils/index.ts @@ -275,6 +275,20 @@ export const getEndingNodes = ( error = new InternalFlowiseError(StatusCodes.INTERNAL_SERVER_ERROR, `Ending node must be either a Chain or Agent or Engine`) continue } + + if ( + endingNodeData.outputs && + Object.keys(endingNodeData.outputs).length && + !Object.values(endingNodeData.outputs ?? {}).includes(endingNodeData.name) + ) { + // The actual use case is that the Output of LLMChain is `Output Prediction`, + // which is not an EndingNode at this time. + error = new InternalFlowiseError( + StatusCodes.INTERNAL_SERVER_ERROR, + `Output of ${endingNodeData.label} (${endingNodeData.id}) must be ${endingNodeData.label}, can't be an Output Prediction` + ) + continue + } } verifiedEndingNodes.push(endingNode) }