Skip to content

Commit 6fb97ce

Browse files
authored
Fix missing flowData for CustomTemplate Tool during import (#5542)
fix(services/export-import): import missing flowData for Custom Template Tool
1 parent be9780c commit 6fb97ce

File tree

1 file changed

+11
-2
lines changed
  • packages/server/src/services/export-import

1 file changed

+11
-2
lines changed

packages/server/src/services/export-import/index.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@ import { Tool } from '../../database/entities/Tool'
1313
import { Variable } from '../../database/entities/Variable'
1414
import { InternalFlowiseError } from '../../errors/internalFlowiseError'
1515
import { getErrorMessage } from '../../errors/utils'
16+
import { Platform } from '../../Interface'
1617
import assistantsService from '../../services/assistants'
1718
import chatflowsService from '../../services/chatflows'
1819
import { getRunningExpressApp } from '../../utils/getRunningExpressApp'
1920
import { checkUsageLimit } from '../../utils/quotaUsage'
21+
import { sanitizeNullBytes } from '../../utils/sanitize.util'
2022
import assistantService from '../assistants'
2123
import chatMessagesService from '../chat-messages'
2224
import chatflowService from '../chatflows'
@@ -25,8 +27,6 @@ import executionService, { ExecutionFilters } from '../executions'
2527
import marketplacesService from '../marketplaces'
2628
import toolsService from '../tools'
2729
import variableService from '../variables'
28-
import { Platform } from '../../Interface'
29-
import { sanitizeNullBytes } from '../../utils/sanitize.util'
3030

3131
type ExportInput = {
3232
agentflow: boolean
@@ -596,6 +596,15 @@ function reduceSpaceForChatflowFlowData(chatflows: ChatFlow[]) {
596596
function insertWorkspaceId(importedData: any, activeWorkspaceId?: string) {
597597
if (!activeWorkspaceId) return importedData
598598
importedData.forEach((item: any) => {
599+
if (item.type === 'Tool') {
600+
// TODO: This is a temporary fix where export data for CustomTemplate type Tool need to be changed in the future.
601+
// Also handles backward compatibility for previously exported data where CustomTemplate type Tool does not have flowData field.
602+
item.flowData = JSON.stringify({
603+
iconSrc: item.iconSrc,
604+
schema: item.schema,
605+
func: item.func
606+
})
607+
}
599608
item.workspaceId = activeWorkspaceId
600609
})
601610
return importedData

0 commit comments

Comments
 (0)