@@ -13,10 +13,12 @@ import { Tool } from '../../database/entities/Tool'
1313import { Variable } from '../../database/entities/Variable'
1414import { InternalFlowiseError } from '../../errors/internalFlowiseError'
1515import { getErrorMessage } from '../../errors/utils'
16+ import { Platform } from '../../Interface'
1617import assistantsService from '../../services/assistants'
1718import chatflowsService from '../../services/chatflows'
1819import { getRunningExpressApp } from '../../utils/getRunningExpressApp'
1920import { checkUsageLimit } from '../../utils/quotaUsage'
21+ import { sanitizeNullBytes } from '../../utils/sanitize.util'
2022import assistantService from '../assistants'
2123import chatMessagesService from '../chat-messages'
2224import chatflowService from '../chatflows'
@@ -25,8 +27,6 @@ import executionService, { ExecutionFilters } from '../executions'
2527import marketplacesService from '../marketplaces'
2628import toolsService from '../tools'
2729import variableService from '../variables'
28- import { Platform } from '../../Interface'
29- import { sanitizeNullBytes } from '../../utils/sanitize.util'
3030
3131type ExportInput = {
3232 agentflow : boolean
@@ -596,6 +596,15 @@ function reduceSpaceForChatflowFlowData(chatflows: ChatFlow[]) {
596596function 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