From a8637a0bc6ac19859ce1ff468d0404ac73bc70bb Mon Sep 17 00:00:00 2001
From: agobrech <45268029+agobrech@users.noreply.github.com>
Date: Tue, 31 Jan 2023 09:25:08 +0100
Subject: [PATCH] fix(Set Node): Fix behaviour when selecting continueOnFail &
 PairedItem (#5257)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* 🐛 Fix bug on continueOnFail with pairedItem

* 🐛  Fix pairedItem continueOnFail for the Set Node

* 🎨  Add the ExpressionExtensionError back

* :zap: import fix

---------

Co-authored-by: Michael Kret <michael.k@radency.com>
---
 packages/core/src/NodeExecuteFunctions.ts | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/packages/core/src/NodeExecuteFunctions.ts b/packages/core/src/NodeExecuteFunctions.ts
index c21da5fc2e..f1fe6adb95 100644
--- a/packages/core/src/NodeExecuteFunctions.ts
+++ b/packages/core/src/NodeExecuteFunctions.ts
@@ -70,6 +70,7 @@ import {
 	OAuth2GrantType,
 	deepCopy,
 	fileTypeFromMimeType,
+	ExpressionError,
 } from 'n8n-workflow';
 
 import { Agent } from 'https';
@@ -1806,12 +1807,15 @@ export function getNodeParameter(
 			additionalKeys,
 			executeData,
 		);
-
 		cleanupParameterData(returnData);
 	} catch (e) {
-		if (e.context) e.context.parameter = parameterName;
-		e.cause = value;
-		throw e;
+		if (e instanceof ExpressionError && node.continueOnFail && node.name === 'Set') {
+			returnData = [{ name: undefined, value: undefined }];
+		} else {
+			if (e.context) e.context.parameter = parameterName;
+			e.cause = value;
+			throw e;
+		}
 	}
 
 	// This is outside the try/catch because it throws errors with proper messages