diff --git a/CHANGELOG.md b/CHANGELOG.md index 6aede3e..d5daa11 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -139,6 +139,22 @@ Each node must have a unique ID. Generate a new UUID using crypto.randomUUID() - Conceived by Romuald Członkowski - [www.aiadvisors.pl/en](https://www.aiadvisors.pl/en) +### 🐛 Bug Fixes + +**Critical: AI Agent Validator Not Executing** + +Fixed nodeType format mismatch bug that prevented the AI Agent validator (Quick Win #3 above) from ever executing. + +**The Bug**: Switch case checked for `@n8n/n8n-nodes-langchain.agent` but nodeType was normalized to `nodes-langchain.agent` first, so validator never matched. + +**Fix**: Changed `enhanced-config-validator.ts:322` from `case '@n8n/n8n-nodes-langchain.agent':` to `case 'nodes-langchain.agent':` + +**Impact**: Without this fix, the AI Agent validator code from Quick Win #3 would never execute, missing 179 configuration errors (30% of failures). + +**Testing**: Added verification test in `enhanced-config-validator.test.ts:1137-1169` to ensure validator executes. + +**Discovery**: Found by n8n-mcp-tester agent during post-deployment verification of Quick Win #3. + ## [2.22.12] - 2025-01-08 ### 🐛 Bug Fixes diff --git a/data/nodes.db b/data/nodes.db index 288b78a..caaa50b 100644 Binary files a/data/nodes.db and b/data/nodes.db differ diff --git a/src/services/enhanced-config-validator.ts b/src/services/enhanced-config-validator.ts index 6c9c90f..3effd29 100644 --- a/src/services/enhanced-config-validator.ts +++ b/src/services/enhanced-config-validator.ts @@ -319,7 +319,7 @@ export class EnhancedConfigValidator extends ConfigValidator { NodeSpecificValidators.validateMySQL(context); break; - case '@n8n/n8n-nodes-langchain.agent': + case 'nodes-langchain.agent': NodeSpecificValidators.validateAIAgent(context); break; diff --git a/tests/unit/services/enhanced-config-validator.test.ts b/tests/unit/services/enhanced-config-validator.test.ts index 64df123..ac667cf 100644 --- a/tests/unit/services/enhanced-config-validator.test.ts +++ b/tests/unit/services/enhanced-config-validator.test.ts @@ -14,7 +14,8 @@ vi.mock('@/services/node-specific-validators', () => ({ validateMongoDB: vi.fn(), validateWebhook: vi.fn(), validatePostgres: vi.fn(), - validateMySQL: vi.fn() + validateMySQL: vi.fn(), + validateAIAgent: vi.fn() } })); @@ -1132,5 +1133,39 @@ describe('EnhancedConfigValidator', () => { }).not.toThrow(); }); }); + + describe('AI Agent node validation', () => { + it('should call validateAIAgent for AI Agent nodes', () => { + const nodeType = 'nodes-langchain.agent'; + const config = { + promptType: 'define', + text: 'You are a helpful assistant' + }; + const properties = [ + { name: 'promptType', type: 'options', required: true }, + { name: 'text', type: 'string', required: false } + ]; + + EnhancedConfigValidator.validateWithMode( + nodeType, + config, + properties, + 'operation', + 'ai-friendly' + ); + + // Verify the validator was called (fix for issue where it wasn't being called at all) + expect(NodeSpecificValidators.validateAIAgent).toHaveBeenCalledTimes(1); + + // Verify it was called with a context object containing our config + const callArgs = (NodeSpecificValidators.validateAIAgent as any).mock.calls[0][0]; + expect(callArgs).toHaveProperty('config'); + expect(callArgs.config).toEqual(config); + expect(callArgs).toHaveProperty('errors'); + expect(callArgs).toHaveProperty('warnings'); + expect(callArgs).toHaveProperty('suggestions'); + expect(callArgs).toHaveProperty('autofix'); + }); + }); }); }); \ No newline at end of file