From de96717fd74c7341d3b21b511647b35e9c6784c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=A4=95=E0=A4=BE=E0=A4=B0=E0=A4=A4=E0=A5=8B=E0=A4=AB?= =?UTF-8?q?=E0=A5=8D=E0=A4=AB=E0=A5=87=E0=A4=B2=E0=A4=B8=E0=A5=8D=E0=A4=95?= =?UTF-8?q?=E0=A5=8D=E0=A4=B0=E0=A4=BF=E0=A4=AA=E0=A5=8D=E0=A4=9F=E2=84=A2?= Date: Thu, 3 Aug 2023 11:46:24 +0200 Subject: [PATCH 1/3] add a test that should fail --- packages/workflow/test/AugmentObject.test.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/workflow/test/AugmentObject.test.ts b/packages/workflow/test/AugmentObject.test.ts index ab208f6c2189a..25cc6d4317b23 100644 --- a/packages/workflow/test/AugmentObject.test.ts +++ b/packages/workflow/test/AugmentObject.test.ts @@ -570,6 +570,7 @@ describe('AugmentObject', () => { augmentedObject.x.z = 5; expect('z' in augmentedObject.x).toBe(true); + expect('y' in augmentedObject.x).toBe(true); }); }); }); From d50589c3540a9c9552a07188812e0589d2ea34cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=A4=95=E0=A4=BE=E0=A4=B0=E0=A4=A4=E0=A5=8B=E0=A4=AB?= =?UTF-8?q?=E0=A5=8D=E0=A4=AB=E0=A5=87=E0=A4=B2=E0=A4=B8=E0=A5=8D=E0=A4=95?= =?UTF-8?q?=E0=A5=8D=E0=A4=B0=E0=A4=BF=E0=A4=AA=E0=A5=8D=E0=A4=9F=E2=84=A2?= Date: Thu, 3 Aug 2023 11:47:41 +0200 Subject: [PATCH 2/3] fix(core): Fix property existence checks on AugmentObject Fixes https://community.n8n.io/t/code-node-returns-full-item-object-on-node-all/28823 --- packages/workflow/src/AugmentObject.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/workflow/src/AugmentObject.ts b/packages/workflow/src/AugmentObject.ts index dd4e868f85bcb..b681b08aad300 100644 --- a/packages/workflow/src/AugmentObject.ts +++ b/packages/workflow/src/AugmentObject.ts @@ -134,8 +134,7 @@ export function augmentObject(data: T): T { }, has(target, key) { if (deletedProperties.indexOf(key) !== -1) return false; - const newKeys = Object.keys(newData); - return Reflect.has(newKeys.length ? newData : target, key); + return Reflect.has(newData, key) || Reflect.has(target, key); }, ownKeys(target) { const originalKeys = Reflect.ownKeys(target); From 27dd83387356469fb19dcbabfb0bf887abdbcd1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=A4=95=E0=A4=BE=E0=A4=B0=E0=A4=A4=E0=A5=8B=E0=A4=AB?= =?UTF-8?q?=E0=A5=8D=E0=A4=AB=E0=A5=87=E0=A4=B2=E0=A4=B8=E0=A5=8D=E0=A4=95?= =?UTF-8?q?=E0=A5=8D=E0=A4=B0=E0=A4=BF=E0=A4=AA=E0=A5=8D=E0=A4=9F=E2=84=A2?= Date: Thu, 3 Aug 2023 11:48:06 +0200 Subject: [PATCH 3/3] use nullish coalescing operator --- packages/workflow/src/AugmentObject.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/workflow/src/AugmentObject.ts b/packages/workflow/src/AugmentObject.ts index b681b08aad300..01e6f03ecb49d 100644 --- a/packages/workflow/src/AugmentObject.ts +++ b/packages/workflow/src/AugmentObject.ts @@ -33,7 +33,7 @@ export function augmentArray(data: T[]): T[] { return Reflect.deleteProperty(getData(), key); }, get(target, key: string, receiver): unknown { - const value = Reflect.get(newData !== undefined ? newData : target, key, receiver) as unknown; + const value = Reflect.get(newData ?? target, key, receiver) as unknown; const newValue = augment(value); if (newValue !== value) { newData = getData(); @@ -54,10 +54,10 @@ export function augmentArray(data: T[]): T[] { return Object.getOwnPropertyDescriptor(data, key) ?? defaultPropertyDescriptor; }, has(target, key) { - return Reflect.has(newData !== undefined ? newData : target, key); + return Reflect.has(newData ?? target, key); }, ownKeys(target) { - return Reflect.ownKeys(newData !== undefined ? newData : target); + return Reflect.ownKeys(newData ?? target); }, set(target, key: string, newValue: unknown) { // Always proxy all objects. Like that we can check in get simply if it