From f1184ccab5dd7f0f7a80a5f39cf4f7bdb387f7ae Mon Sep 17 00:00:00 2001 From: Michael Kret <88898367+michael-radency@users.noreply.github.com> Date: Wed, 4 Jan 2023 15:54:24 +0200 Subject: [PATCH] fix(Google Sheets Node): Fix exception when no Values to Send are set --- .../v2/actions/sheet/appendOrUpdate.operation.ts | 11 ++++++++--- .../Google/Sheet/v2/actions/sheet/update.operation.ts | 11 ++++++++--- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/packages/nodes-base/nodes/Google/Sheet/v2/actions/sheet/appendOrUpdate.operation.ts b/packages/nodes-base/nodes/Google/Sheet/v2/actions/sheet/appendOrUpdate.operation.ts index d176c5ad24..04620109d6 100644 --- a/packages/nodes-base/nodes/Google/Sheet/v2/actions/sheet/appendOrUpdate.operation.ts +++ b/packages/nodes-base/nodes/Google/Sheet/v2/actions/sheet/appendOrUpdate.operation.ts @@ -253,9 +253,14 @@ export async function execute( } else { const valueToMatchOn = this.getNodeParameter('valueToMatchOn', i) as string; - const fields = ( - (this.getNodeParameter('fieldsUi.values', i, {}) as IDataObject[]) || [] - ).reduce((acc, entry) => { + const valuesToSend = this.getNodeParameter('fieldsUi.values', i, []) as IDataObject[]; + if (!valuesToSend?.length) { + throw new NodeOperationError( + this.getNode(), + "At least one value has to be added under 'Values to Send'", + ); + } + const fields = valuesToSend.reduce((acc, entry) => { if (entry.column === 'newColumn') { const columnName = entry.columnName as string; diff --git a/packages/nodes-base/nodes/Google/Sheet/v2/actions/sheet/update.operation.ts b/packages/nodes-base/nodes/Google/Sheet/v2/actions/sheet/update.operation.ts index 78a2006f8e..17a1cbe225 100644 --- a/packages/nodes-base/nodes/Google/Sheet/v2/actions/sheet/update.operation.ts +++ b/packages/nodes-base/nodes/Google/Sheet/v2/actions/sheet/update.operation.ts @@ -251,9 +251,14 @@ export async function execute( } else { const valueToMatchOn = this.getNodeParameter('valueToMatchOn', i) as string; - const fields = ( - (this.getNodeParameter('fieldsUi.values', i, {}) as IDataObject[]) || [] - ).reduce((acc, entry) => { + const valuesToSend = this.getNodeParameter('fieldsUi.values', i, []) as IDataObject[]; + if (!valuesToSend?.length) { + throw new NodeOperationError( + this.getNode(), + "At least one value has to be added under 'Values to Send'", + ); + } + const fields = valuesToSend.reduce((acc, entry) => { if (entry.column === 'newColumn') { const columnName = entry.columnName as string;