mirror of
https://github.com/czlonkowski/n8n-mcp.git
synced 2026-01-30 06:22:04 +00:00
Issue #248: Settings validation error - Add callerPolicy to workflowSettingsSchema to support valid n8n property - Implement settings filtering in cleanWorkflowForUpdate() to prevent API errors - Filter out UI-only properties like timeSavedPerExecution - Preserve only whitelisted settings properties - Add comprehensive unit tests for settings filtering Issue #249: Misleading error messages for addConnection - Enhanced validateAddConnection() with parameter validation - Detect common mistakes like using sourceNodeId/targetNodeId instead of source/target - Provide helpful error messages with correct parameter names - List available nodes when source/target not found - Add unit tests for all error scenarios All tests passing (183 total): - n8n-validation: 73/73 tests (100% coverage) - workflow-diff-engine: 110/110 tests 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -359,6 +359,126 @@ describe('n8n-validation', () => {
|
||||
const cleaned = cleanWorkflowForUpdate(workflow);
|
||||
expect(cleaned).not.toHaveProperty('settings');
|
||||
});
|
||||
|
||||
it('should filter out UI-only settings properties like timeSavedPerExecution (Issue #248)', () => {
|
||||
const workflow = {
|
||||
name: 'Test Workflow',
|
||||
nodes: [],
|
||||
connections: {},
|
||||
settings: {
|
||||
executionOrder: 'v1' as const,
|
||||
saveDataSuccessExecution: 'none' as const,
|
||||
timeSavedPerExecution: 5, // UI-only property - should be removed
|
||||
unknownProperty: 'test', // Unknown property - should be removed
|
||||
},
|
||||
} as any;
|
||||
|
||||
const cleaned = cleanWorkflowForUpdate(workflow);
|
||||
|
||||
// Should keep valid properties
|
||||
expect(cleaned.settings).toHaveProperty('executionOrder', 'v1');
|
||||
expect(cleaned.settings).toHaveProperty('saveDataSuccessExecution', 'none');
|
||||
|
||||
// Should remove invalid properties
|
||||
expect(cleaned.settings).not.toHaveProperty('timeSavedPerExecution');
|
||||
expect(cleaned.settings).not.toHaveProperty('unknownProperty');
|
||||
});
|
||||
|
||||
it('should preserve callerPolicy property in settings (Issue #248)', () => {
|
||||
const workflow = {
|
||||
name: 'Test Workflow',
|
||||
nodes: [],
|
||||
connections: {},
|
||||
settings: {
|
||||
executionOrder: 'v1' as const,
|
||||
saveDataSuccessExecution: 'none' as const,
|
||||
callerPolicy: 'workflowsFromSameOwner' as const,
|
||||
errorWorkflow: 'N2O2nZy3aUiBRGFN',
|
||||
},
|
||||
} as any;
|
||||
|
||||
const cleaned = cleanWorkflowForUpdate(workflow);
|
||||
|
||||
// All these properties should be preserved
|
||||
expect(cleaned.settings).toHaveProperty('executionOrder', 'v1');
|
||||
expect(cleaned.settings).toHaveProperty('saveDataSuccessExecution', 'none');
|
||||
expect(cleaned.settings).toHaveProperty('callerPolicy', 'workflowsFromSameOwner');
|
||||
expect(cleaned.settings).toHaveProperty('errorWorkflow', 'N2O2nZy3aUiBRGFN');
|
||||
});
|
||||
|
||||
it('should handle settings with both valid and invalid properties (Issue #248)', () => {
|
||||
const workflow = {
|
||||
name: 'Test Workflow',
|
||||
nodes: [],
|
||||
connections: {},
|
||||
settings: {
|
||||
executionOrder: 'v1' as const,
|
||||
timezone: 'America/New_York',
|
||||
timeSavedPerExecution: 10, // Invalid - should be removed
|
||||
callerPolicy: 'any' as const, // Valid - should be kept
|
||||
uiProperty: { nested: 'value' }, // Invalid - should be removed
|
||||
saveExecutionProgress: true, // Valid - should be kept
|
||||
},
|
||||
} as any;
|
||||
|
||||
const cleaned = cleanWorkflowForUpdate(workflow);
|
||||
|
||||
// Valid properties should be kept
|
||||
expect(cleaned.settings).toHaveProperty('executionOrder', 'v1');
|
||||
expect(cleaned.settings).toHaveProperty('timezone', 'America/New_York');
|
||||
expect(cleaned.settings).toHaveProperty('callerPolicy', 'any');
|
||||
expect(cleaned.settings).toHaveProperty('saveExecutionProgress', true);
|
||||
|
||||
// Invalid properties should be removed
|
||||
expect(cleaned.settings).not.toHaveProperty('timeSavedPerExecution');
|
||||
expect(cleaned.settings).not.toHaveProperty('uiProperty');
|
||||
});
|
||||
|
||||
it('should handle empty settings object', () => {
|
||||
const workflow = {
|
||||
name: 'Test Workflow',
|
||||
nodes: [],
|
||||
connections: {},
|
||||
settings: {},
|
||||
} as any;
|
||||
|
||||
const cleaned = cleanWorkflowForUpdate(workflow);
|
||||
expect(cleaned.settings).toEqual({});
|
||||
});
|
||||
|
||||
it('should preserve all whitelisted settings properties', () => {
|
||||
const workflow = {
|
||||
name: 'Test Workflow',
|
||||
nodes: [],
|
||||
connections: {},
|
||||
settings: {
|
||||
executionOrder: 'v0' as const,
|
||||
timezone: 'UTC',
|
||||
saveDataErrorExecution: 'all' as const,
|
||||
saveDataSuccessExecution: 'none' as const,
|
||||
saveManualExecutions: false,
|
||||
saveExecutionProgress: false,
|
||||
executionTimeout: 300,
|
||||
errorWorkflow: 'error-workflow-id',
|
||||
callerPolicy: 'workflowsFromAList' as const,
|
||||
},
|
||||
} as any;
|
||||
|
||||
const cleaned = cleanWorkflowForUpdate(workflow);
|
||||
|
||||
// All whitelisted properties should be preserved
|
||||
expect(cleaned.settings).toEqual({
|
||||
executionOrder: 'v0',
|
||||
timezone: 'UTC',
|
||||
saveDataErrorExecution: 'all',
|
||||
saveDataSuccessExecution: 'none',
|
||||
saveManualExecutions: false,
|
||||
saveExecutionProgress: false,
|
||||
executionTimeout: 300,
|
||||
errorWorkflow: 'error-workflow-id',
|
||||
callerPolicy: 'workflowsFromAList',
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user