MCPcopy
hub / github.com/FlowiseAI/Flowise / getChatflowById

Function getChatflowById

packages/server/src/services/chatflows/index.ts:280–305  ·  view source on GitHub ↗
(chatflowId: string, workspaceId?: string)

Source from the content-addressed store, hash-verified

278}
279
280const getChatflowById = async (chatflowId: string, workspaceId?: string): Promise<any> => {
281 try {
282 if (!isValidUUID(chatflowId)) {
283 throw new InternalFlowiseError(StatusCodes.BAD_REQUEST, ChatflowErrorMessage.INVALID_CHATFLOW_ID)
284 }
285 const appServer = getRunningExpressApp()
286 const dbResponse = await appServer.AppDataSource.getRepository(ChatFlow).findOne({
287 where: {
288 id: chatflowId,
289 ...(workspaceId ? { workspaceId } : {})
290 }
291 })
292 if (!dbResponse) {
293 throw new InternalFlowiseError(StatusCodes.NOT_FOUND, `Chatflow ${chatflowId} not found in the database!`)
294 }
295 return dbResponse
296 } catch (error) {
297 if (error instanceof InternalFlowiseError) {
298 throw error
299 }
300 throw new InternalFlowiseError(
301 StatusCodes.INTERNAL_SERVER_ERROR,
302 `Error: chatflowsService.getChatflowById - ${getErrorMessage(error)}`
303 )
304 }
305}
306
307/** Resolves a chatflow only if it belongs to the given workspace; rejects when workspaceId is missing (prevents unscoped lookup). */
308const getChatflowByIdForWorkspace = async (chatflowId: string, workspaceId: string | undefined): Promise<any> => {

Callers 2

deleteChatflowFunction · 0.70

Calls 3

getRunningExpressAppFunction · 0.90
getErrorMessageFunction · 0.90
isValidUUIDFunction · 0.85

Tested by

no test coverage detected