mirror of
https://github.com/czlonkowski/n8n-mcp.git
synced 2026-02-08 14:23:08 +00:00
fix: add string normalization for special characters in node names
Fixes #270 ## Problem Connection operations (addConnection, removeConnection, etc.) failed when node names contained special characters like apostrophes, quotes, or backslashes. Default n8n Manual Trigger node: "When clicking 'Execute workflow'" caused: - Error: "Source node not found: \"When clicking 'Execute workflow'\"" - Node shown in available nodes list but string matching failed - Users had to use node IDs as workaround ## Root Cause The `findNode()` method in WorkflowDiffEngine performed exact string matching without normalization. When node names contained special characters, escaping differences between input strings and stored node names caused match failures. ## Solution ### 1. String Normalization (Primary Fix) Added `normalizeNodeName()` helper method: - Unescapes single quotes: \' → ' - Unescapes double quotes: \" → " - Unescapes backslashes: \\ → \ - Normalizes whitespace Updated `findNode()` to normalize both search string and node names before comparison, while preserving exact UUID matching for node IDs. ### 2. Improved Error Messages Enhanced validation error messages to show: - Node IDs (first 8 characters) for quick reference - Available nodes with both names and ID prefixes - Helpful tip about using node IDs for special characters ### 3. Comprehensive Tests Added 6 new test cases covering: - Apostrophes (default Manual Trigger scenario) - Double quotes - Backslashes - Mixed special characters - removeConnection with special chars - updateNode with special chars All tests passing: 116/116 in workflow-diff-engine.test.ts ### 4. Documentation Updated tool documentation to note: - Special character support since v2.15.6 - Node IDs preferred for best compatibility ## Affected Operations All 8 operations using findNode() now support special characters: - addConnection, removeConnection, updateConnection - removeNode, updateNode, moveNode - enableNode, disableNode ## Testing Validated with n8n-mcp-tester agent: ✅ addConnection with apostrophes works ✅ Default Manual Trigger name works ✅ Improved error messages show IDs ✅ Double quotes handled correctly ✅ Node IDs work as alternative ## Impact - Fixes common user pain point with default n8n node names - Backward compatible (only makes matching MORE permissive) - Minimal performance impact (normalization only during validation) - Centralized fix (one method fixes all 8 operations) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -96,6 +96,8 @@ Add **ignoreErrors: true** to removeConnection operations to prevent failures wh
|
||||
'continueOnError breaks atomic guarantees - use with caution',
|
||||
'Order matters for dependent operations (e.g., must add node before connecting to it)',
|
||||
'Node references accept ID or name, but name must be unique',
|
||||
'Node names with special characters (apostrophes, quotes) work correctly since v2.15.6 (Issue #270 fixed)',
|
||||
'For best compatibility, prefer node IDs over names when dealing with special characters',
|
||||
'Use "updates" property for updateNode operations: {type: "updateNode", updates: {...}}',
|
||||
'cleanStaleConnections removes ALL broken connections - cannot be selective',
|
||||
'replaceConnections overwrites entire connections object - all previous connections lost'
|
||||
|
||||
Reference in New Issue
Block a user