fix: resolve empty settings validation error in workflow updates (#431)

Fixed critical bug where n8n_update_partial_workflow failed with "request/body
must NOT have additional properties" error when workflows had no settings or
only non-whitelisted settings.

Root Cause:
- cleanWorkflowForUpdate() was sending empty settings: {} objects
- n8n API rejects empty settings as additional properties violation
- Occurred when workflow had no settings or only filtered properties

Changes:
- Modified cleanWorkflowForUpdate() to delete settings property when empty
- Enhanced applyUpdateSettings() to prevent creating empty settings
- Fixed 3 incorrect tests expecting empty settings objects
- Added 2 comprehensive tests for edge cases

Testing:
- All 75 unit tests in n8n-validation.test.ts passing
- Build and type checking successful
- New tests cover all empty settings scenarios

Related: #431, #248
Related n8n issue: n8n-io/n8n#19587

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

Conceived by Romuald Członkowski - https://www.aiadvisors.pl/en
This commit is contained in:
czlonkowski
2025-11-20 16:33:42 +01:00
parent 47d9f55dc5
commit d8a08947fa
5 changed files with 101 additions and 11 deletions

View File

@@ -189,10 +189,18 @@ export function cleanWorkflowForUpdate(workflow: Workflow): Partial<Workflow> {
filteredSettings[key] = (cleanedWorkflow.settings as any)[key];
}
}
cleanedWorkflow.settings = filteredSettings;
// Only include settings if it has properties after filtering
// n8n API rejects empty settings objects
if (Object.keys(filteredSettings).length > 0) {
cleanedWorkflow.settings = filteredSettings;
} else {
delete cleanedWorkflow.settings;
}
} else {
// No settings provided - use empty object for safety
cleanedWorkflow.settings = {};
// No settings provided - remove the property entirely
// n8n API rejects empty settings objects
delete cleanedWorkflow.settings;
}
return cleanedWorkflow;