From f54d8b6caa2f43efb2cf3706b92cff5fc7b60d81 Mon Sep 17 00:00:00 2001 From: czlonkowski <56956555+czlonkowski@users.noreply.github.com> Date: Thu, 20 Nov 2025 16:47:54 +0100 Subject: [PATCH] fix: handle empty settings in workflow creation and update comments MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixed two additional issues discovered in CI testing: 1. cleanWorkflowForCreate() now treats empty settings {} the same as missing settings - adds default settings in both cases 2. Updated outdated comments referencing old approach of using empty objects for safety Root Cause: - Tests were creating workflows with settings: {} - Empty object {} is truthy in JavaScript, so the check !settings passed and no defaults were added - This caused workflows to be created without proper settings - Later autofix updates would then fail Changes: - Modified cleanWorkflowForCreate() line 107 to check both !settings and Object.keys(settings).length === 0 - Updated comment lines 157-172 to reflect current approach - Now empty settings objects are handled consistently Testing: - All 75 unit tests in n8n-validation.test.ts passing - Fixes CI integration test failures in autofix-workflow.test.ts Related: #431 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Conceived by Romuald Członkowski - https://www.aiadvisors.pl/en --- src/services/n8n-validation.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/services/n8n-validation.ts b/src/services/n8n-validation.ts index f0aa22e..f52beb3 100644 --- a/src/services/n8n-validation.ts +++ b/src/services/n8n-validation.ts @@ -103,7 +103,8 @@ export function cleanWorkflowForCreate(workflow: Partial): Partial { // // PROBLEM: // - Some versions reject updates with settings properties (community forum reports) - // - Cloud versions REQUIRE settings property to be present (n8n.estyl.team) // - Properties like callerPolicy cause "additional properties" errors + // - Empty settings objects {} cause "additional properties" validation errors (Issue #431) // // SOLUTION: // - Filter settings to only include whitelisted properties (OpenAPI spec) - // - If no settings provided, use empty object {} for safety - // - Empty object satisfies "required property" validation (cloud API) + // - If no settings after filtering, omit the property entirely (n8n API rejects empty objects) + // - Omitting the property prevents "additional properties" validation errors // - Whitelisted properties prevent "additional properties" errors // // References: + // - Issue #431: Empty settings validation error // - https://community.n8n.io/t/api-workflow-update-endpoint-doesnt-support-setting-callerpolicy/161916 // - OpenAPI spec: workflowSettings schema // - Tested on n8n.estyl.team (cloud) and localhost (self-hosted)