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:
16
CHANGELOG.md
16
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
|
||||
|
||||
BIN
data/nodes.db
BIN
data/nodes.db
Binary file not shown.
@@ -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;
|
||||
|
||||
|
||||
@@ -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