mirror of
https://github.com/czlonkowski/n8n-mcp.git
synced 2026-01-30 06:22:04 +00:00
fix: AI Agent validator not executing due to nodeType format mismatch (Critical)
Fixed critical bug where AI Agent validator never executed, missing 179 configuration errors (30% of all telemetry-identified failures). The Bug: - Switch case checked for '@n8n/n8n-nodes-langchain.agent' (full package format) - But nodeType was normalized to 'nodes-langchain.agent' before reaching switch - Result: AI Agent validator never matched, never executed The Fix: - Changed case to 'nodes-langchain.agent' to match normalized format - Now correctly catches prompt configuration, maxIterations, error handling issues Files Changed: - src/services/enhanced-config-validator.ts:322 - Fixed nodeType format - tests/unit/services/enhanced-config-validator.test.ts - Added validateAIAgent to mock and verification test - CHANGELOG.md - Added bug fix section to 2.22.13 (not separate version) Testing: - npm test -- tests/unit/services/enhanced-config-validator.test.ts - ✓ All 51 tests pass including new AI Agent validation test Discovery: Discovered by n8n-mcp-tester agent during post-deployment verification of 2.22.13 improvements. The agent attempted to validate an AI Agent node configuration and discovered the validator was never being called. Impact: - Without fix: 179 AI Agent configuration errors (30%) go undetected - With fix: All AI Agent validation rules now execute correctly Version: 2.22.13 (kept under same version as original implementation) Concieved by Romuald Członkowski - www.aiadvisors.pl/en
This commit is contained in:
@@ -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');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user