Bugfix/update workspaceId to vars (#4891)

update workspaceId to vars
This commit is contained in:
Henry Heng 2025-07-17 15:43:13 +01:00 committed by GitHub
parent 9839009823
commit 8a6b95ef0e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 21 additions and 6 deletions

View File

@ -943,10 +943,13 @@ export const getVars = async (
nodeData: INodeData, nodeData: INodeData,
options: ICommonObject options: ICommonObject
) => { ) => {
if (!options.workspaceId) {
return []
}
const variables = const variables =
((await appDataSource ((await appDataSource
.getRepository(databaseEntities['Variable']) .getRepository(databaseEntities['Variable'])
.findBy(options.workspaceId ? { workspaceId: Equal(options.workspaceId) } : {})) as IVariable[]) ?? [] .findBy({ workspaceId: Equal(options.workspaceId) })) as IVariable[]) ?? []
// override variables defined in overrideConfig // override variables defined in overrideConfig
// nodeData.inputs.vars is an Object, check each property and override the variable // nodeData.inputs.vars is an Object, check each property and override the variable

View File

@ -86,7 +86,8 @@ const executeCustomFunction = async (req: Request, res: Response, next: NextFunc
) )
} }
const orgId = req.user?.activeOrganizationId const orgId = req.user?.activeOrganizationId
const apiResponse = await nodesService.executeCustomFunction(req.body, orgId) const workspaceId = req.user?.activeWorkspaceId
const apiResponse = await nodesService.executeCustomFunction(req.body, workspaceId, orgId)
return res.json(apiResponse) return res.json(apiResponse)
} catch (error) { } catch (error) {
next(error) next(error)

View File

@ -122,14 +122,15 @@ const getSingleNodeAsyncOptions = async (nodeName: string, requestBody: any): Pr
} }
// execute custom function node // execute custom function node
const executeCustomFunction = async (requestBody: any, orgId?: string) => { const executeCustomFunction = async (requestBody: any, workspaceId?: string, orgId?: string) => {
const appServer = getRunningExpressApp() const appServer = getRunningExpressApp()
const executeData = { const executeData = {
appDataSource: appServer.AppDataSource, appDataSource: appServer.AppDataSource,
componentNodes: appServer.nodesPool.componentNodes, componentNodes: appServer.nodesPool.componentNodes,
data: requestBody, data: requestBody,
isExecuteCustomFunction: true, isExecuteCustomFunction: true,
orgId orgId,
workspaceId
} }
if (process.env.MODE === MODE.QUEUE) { if (process.env.MODE === MODE.QUEUE) {

View File

@ -147,6 +147,7 @@ const buildAndInitTool = async (chatflowid: string, _chatId?: string, _apiMessag
chatflowid, chatflowid,
chatId, chatId,
orgId, orgId,
workspaceId,
appDataSource: appServer.AppDataSource, appDataSource: appServer.AppDataSource,
databaseEntities, databaseEntities,
analytic: chatflow.analytic analytic: chatflow.analytic

View File

@ -750,6 +750,8 @@ export const executeFlow = async ({
rawOutput: resultText, rawOutput: resultText,
appDataSource, appDataSource,
databaseEntities, databaseEntities,
workspaceId,
orgId,
logger logger
} }
const customFuncNodeInstance = new nodeModule.nodeClass() const customFuncNodeInstance = new nodeModule.nodeClass()

View File

@ -100,6 +100,7 @@ export const createFileAttachment = async (req: Request) => {
const options = { const options = {
retrieveAttachmentChatId: true, retrieveAttachmentChatId: true,
orgId, orgId,
workspaceId,
chatflowid, chatflowid,
chatId chatId
} }

View File

@ -9,11 +9,15 @@ import { IComponentNodes } from '../Interface'
export const executeCustomNodeFunction = async ({ export const executeCustomNodeFunction = async ({
appDataSource, appDataSource,
componentNodes, componentNodes,
data data,
workspaceId,
orgId
}: { }: {
appDataSource: DataSource appDataSource: DataSource
componentNodes: IComponentNodes componentNodes: IComponentNodes
data: any data: any
workspaceId?: string
orgId?: string
}) => { }) => {
try { try {
const body = data const body = data
@ -37,7 +41,9 @@ export const executeCustomNodeFunction = async ({
const options: ICommonObject = { const options: ICommonObject = {
appDataSource, appDataSource,
databaseEntities databaseEntities,
workspaceId,
orgId
} }
const returnData = await newNodeInstance.init(nodeData, '', options) const returnData = await newNodeInstance.init(nodeData, '', options)