diff --git a/packages/components/nodes/tools/MCP/Confluence/ConfluenceMCP.ts b/packages/components/nodes/tools/MCP/Confluence/ConfluenceMCP.ts index 0ae4e97710a..53cc40a1a15 100644 --- a/packages/components/nodes/tools/MCP/Confluence/ConfluenceMCP.ts +++ b/packages/components/nodes/tools/MCP/Confluence/ConfluenceMCP.ts @@ -103,8 +103,12 @@ class Confluence_MCP implements INode { async getTools(nodeData: INodeData, options: ICommonObject): Promise { console.log('[CONFLUENCE MCP DEBUG] ========== getTools START ==========') console.log('[CONFLUENCE MCP DEBUG] Timestamp:', new Date().toISOString()) - console.log('[CONFLUENCE MCP DEBUG] nodeData.credential ID:', nodeData.credential) - console.log('[CONFLUENCE MCP DEBUG] options keys:', Object.keys(options || {}).join(', ')) + console.log('[CONFLUENCE MCP DEBUG] nodeData.credential ID:', nodeData?.credential || 'NONE') + try { + console.log('[CONFLUENCE MCP DEBUG] options keys:', Object.keys(options || {}).join(', ')) + } catch (e) { + console.log('[CONFLUENCE MCP DEBUG] options keys: ERROR -', String(e)) + } console.time('[CONFLUENCE MCP DEBUG] getCredentialData') const credentialData = await getCredentialData(nodeData.credential ?? '', options) diff --git a/packages/components/nodes/tools/MCP/Jira/JiraMCP.ts b/packages/components/nodes/tools/MCP/Jira/JiraMCP.ts index 683a0509a8c..bffc69be37a 100644 --- a/packages/components/nodes/tools/MCP/Jira/JiraMCP.ts +++ b/packages/components/nodes/tools/MCP/Jira/JiraMCP.ts @@ -103,8 +103,12 @@ class Jira_MCP implements INode { async getTools(nodeData: INodeData, options: ICommonObject): Promise { console.log('[JIRA MCP DEBUG] ========== getTools START ==========') console.log('[JIRA MCP DEBUG] Timestamp:', new Date().toISOString()) - console.log('[JIRA MCP DEBUG] nodeData.credential ID:', nodeData.credential) - console.log('[JIRA MCP DEBUG] options keys:', Object.keys(options || {}).join(', ')) + console.log('[JIRA MCP DEBUG] nodeData.credential ID:', nodeData?.credential || 'NONE') + try { + console.log('[JIRA MCP DEBUG] options keys:', Object.keys(options || {}).join(', ')) + } catch (e) { + console.log('[JIRA MCP DEBUG] options keys: ERROR -', String(e)) + } console.time('[JIRA MCP DEBUG] getCredentialData') const credentialData = await getCredentialData(nodeData.credential ?? '', options) diff --git a/packages/components/src/utils.ts b/packages/components/src/utils.ts index 4b403f844b7..a62fcbee9bc 100644 --- a/packages/components/src/utils.ts +++ b/packages/components/src/utils.ts @@ -658,8 +658,8 @@ export const getCredentialData = async (selectedCredentialId: string, options: I return {} } - console.log('[getCredentialData DEBUG] Credential found, name:', credential.name) - console.log('[getCredentialData DEBUG] Credential workspaceId:', credential.workspaceId) + console.log('[getCredentialData DEBUG] Credential found, name:', credential?.name || 'N/A') + console.log('[getCredentialData DEBUG] Credential workspaceId:', credential?.workspaceId || 'N/A') // Decrypt credentialData console.time('[getCredentialData DEBUG] Decrypt credential') diff --git a/packages/server/src/utils/index.ts b/packages/server/src/utils/index.ts index 572f65ab306..940c78d8b44 100644 --- a/packages/server/src/utils/index.ts +++ b/packages/server/src/utils/index.ts @@ -589,7 +589,12 @@ export const buildFlow = async ({ if (!reactFlowNode || reactFlowNode === undefined || nodeIndex < 0) continue try { - const nodeInstanceFilePath = componentNodes[reactFlowNode.data.name].filePath as string + const componentNode = componentNodes[reactFlowNode.data.name] + if (!componentNode) { + logger.error(`[buildFlow] Component node not found in pool: ${reactFlowNode.data.name} (id: ${reactFlowNode.id})`) + continue + } + const nodeInstanceFilePath = componentNode.filePath as string const nodeModule = await import(nodeInstanceFilePath) const newNodeInstance = new nodeModule.nodeClass() @@ -646,11 +651,15 @@ export const buildFlow = async ({ ) { initializedNodes.add(nodeId) } else { - console.log(`[NODE INIT DEBUG] ========== Starting node initialization ==========`) - console.log(`[NODE INIT DEBUG] Node: ${reactFlowNode.data.label} (${reactFlowNode.data.name})`) - console.log(`[NODE INIT DEBUG] Node ID: ${reactFlowNode.data.id}`) - console.log(`[NODE INIT DEBUG] Has credential: ${!!reactFlowNode.data.credential}`) - console.log(`[NODE INIT DEBUG] Timestamp: ${new Date().toISOString()}`) + try { + console.log(`[NODE INIT DEBUG] ========== Starting node initialization ==========`) + console.log(`[NODE INIT DEBUG] Node: ${reactFlowNode?.data?.label || 'UNKNOWN'} (${reactFlowNode?.data?.name || 'UNKNOWN'})`) + console.log(`[NODE INIT DEBUG] Node ID: ${reactFlowNode?.data?.id || 'UNKNOWN'}`) + console.log(`[NODE INIT DEBUG] Has credential: ${!!reactFlowNode?.data?.credential}`) + console.log(`[NODE INIT DEBUG] Timestamp: ${new Date().toISOString()}`) + } catch (e) { + console.log('[NODE INIT DEBUG] Error logging node info:', String(e)) + } // Check and refresh credentials before node initialization if needed console.time(`[NODE INIT DEBUG] checkAndRefreshCredentialsBeforeInit`) @@ -820,7 +829,12 @@ export const clearSessionMemory = async ( // Only clear specific session memory from View Message Dialog UI if (isClearFromViewMessageDialog && memoryType && node.data.label !== memoryType) continue - const nodeInstanceFilePath = componentNodes[node.data.name].filePath as string + const componentNode = componentNodes[node.data.name] + if (!componentNode) { + logger.warn(`[clearSessionMemory] Component node not found: ${node.data.name}`) + continue + } + const nodeInstanceFilePath = componentNode.filePath as string const nodeModule = await import(nodeInstanceFilePath) const newNodeInstance = new nodeModule.nodeClass() const options: ICommonObject = { @@ -1827,7 +1841,12 @@ export const getSessionChatHistory = async ( logger: any, prependMessages?: IMessage[] ): Promise => { - const nodeInstanceFilePath = componentNodes[memoryNode.data.name].filePath as string + const componentNode = componentNodes[memoryNode.data.name] + if (!componentNode) { + logger.error(`[getSessionChatHistory] Component node not found: ${memoryNode.data.name}`) + return [] + } + const nodeInstanceFilePath = componentNode.filePath as string const nodeModule = await import(nodeInstanceFilePath) const newNodeInstance = new nodeModule.nodeClass() @@ -2122,8 +2141,12 @@ export const needsCredentialRefresh = async (credentialId: string, options: { ap * This ensures tokens are fresh before the node tries to use them */ export const checkAndRefreshCredentialsBeforeInit = async (reactFlowNode: IReactFlowNode, options: ICommonObject): Promise => { - console.log('[checkAndRefreshCredentialsBeforeInit DEBUG] Called for node:', reactFlowNode.data.name, reactFlowNode.data.id) - console.log('[checkAndRefreshCredentialsBeforeInit DEBUG] Timestamp:', new Date().toISOString()) + try { + console.log('[checkAndRefreshCredentialsBeforeInit DEBUG] Called for node:', reactFlowNode?.data?.name || 'UNKNOWN', reactFlowNode?.data?.id || 'UNKNOWN') + console.log('[checkAndRefreshCredentialsBeforeInit DEBUG] Timestamp:', new Date().toISOString()) + } catch (e) { + console.log('[checkAndRefreshCredentialsBeforeInit DEBUG] Error logging:', String(e)) + } try { // Check if this node requires OAuth refresh and has credentials