Bugfix/Undefined Flowdata (#2116)

add fix for undefined flowdata
This commit is contained in:
Henry Heng 2024-04-07 12:01:57 +01:00 committed by GitHub
parent 658fa3984e
commit 19e14c4798
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 2 deletions

View File

@ -114,11 +114,14 @@ const updateChatflow = async (req: Request, res: Response, next: NextFunction) =
if (!chatflow) {
return res.status(404).send(`Chatflow ${req.params.id} not found`)
}
const body = req.body
const updateChatFlow = new ChatFlow()
Object.assign(updateChatFlow, body)
updateChatFlow.id = chatflow.id
createRateLimiter(updateChatFlow)
const apiResponse = await chatflowsService.updateChatflow(chatflow, updateChatFlow)
return res.json(apiResponse)
} catch (error) {

View File

@ -217,11 +217,12 @@ const saveChatflow = async (newChatFlow: ChatFlow): Promise<any> => {
const updateChatflow = async (chatflow: ChatFlow, updateChatFlow: ChatFlow): Promise<any> => {
try {
const appServer = getRunningExpressApp()
if (containsBase64File(updateChatFlow)) {
if (updateChatFlow.flowData && containsBase64File(updateChatFlow)) {
updateChatFlow.flowData = updateFlowDataWithFilePaths(chatflow.id, updateChatFlow.flowData)
}
const newDbChatflow = await appServer.AppDataSource.getRepository(ChatFlow).merge(chatflow, updateChatFlow)
const newDbChatflow = appServer.AppDataSource.getRepository(ChatFlow).merge(chatflow, updateChatFlow)
const dbResponse = await appServer.AppDataSource.getRepository(ChatFlow).save(newDbChatflow)
// chatFlowPool is initialized only when a flow is opened
// if the user attempts to rename/update category without opening any flow, chatFlowPool will be undefined
if (appServer.chatflowPool) {