From 6a0f2ca96b9516f90f5add87392ebb39b01f5d21 Mon Sep 17 00:00:00 2001 From: Shireen Missi <94372015+ShireenMissi@users.noreply.github.com> Date: Mon, 19 Aug 2024 13:07:39 +0100 Subject: [PATCH] fix(Read/Write Files from Disk Node): Better error handling when file name missing (no-changelog) (#10463) --- .../Files/ReadWriteFile/actions/read.operation.ts | 11 ++++++++--- .../Files/ReadWriteFile/actions/write.operation.ts | 11 ++++++++--- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/packages/nodes-base/nodes/Files/ReadWriteFile/actions/read.operation.ts b/packages/nodes-base/nodes/Files/ReadWriteFile/actions/read.operation.ts index 3c62c7c0937e7..e8e7b8e69ae55 100644 --- a/packages/nodes-base/nodes/Files/ReadWriteFile/actions/read.operation.ts +++ b/packages/nodes-base/nodes/Files/ReadWriteFile/actions/read.operation.ts @@ -1,4 +1,10 @@ -import type { IExecuteFunctions, INodeExecutionData, INodeProperties } from 'n8n-workflow'; +import { NodeApiError } from 'n8n-workflow'; +import type { + IExecuteFunctions, + INodeExecutionData, + INodeProperties, + JsonObject, +} from 'n8n-workflow'; import glob from 'fast-glob'; import { errorMapper } from '../helpers/utils'; @@ -124,7 +130,6 @@ export async function execute(this: IExecuteFunctions, items: INodeExecutionData }, }); } - returnData.push(...newItems); } catch (error) { const nodeOperatioinError = errorMapper.call(this, error, itemIndex, { @@ -142,7 +147,7 @@ export async function execute(this: IExecuteFunctions, items: INodeExecutionData }); continue; } - throw nodeOperatioinError; + throw new NodeApiError(this.getNode(), error as JsonObject, { itemIndex }); } } diff --git a/packages/nodes-base/nodes/Files/ReadWriteFile/actions/write.operation.ts b/packages/nodes-base/nodes/Files/ReadWriteFile/actions/write.operation.ts index 55796b8064e63..27eb340f4ec8b 100644 --- a/packages/nodes-base/nodes/Files/ReadWriteFile/actions/write.operation.ts +++ b/packages/nodes-base/nodes/Files/ReadWriteFile/actions/write.operation.ts @@ -1,6 +1,11 @@ import type { Readable } from 'stream'; -import type { IExecuteFunctions, INodeExecutionData, INodeProperties } from 'n8n-workflow'; -import { BINARY_ENCODING } from 'n8n-workflow'; +import type { + IExecuteFunctions, + INodeExecutionData, + INodeProperties, + JsonObject, +} from 'n8n-workflow'; +import { BINARY_ENCODING, NodeApiError } from 'n8n-workflow'; import { errorMapper } from '../helpers/utils'; import { updateDisplayOptions } from '@utils/utilities'; @@ -114,7 +119,7 @@ export async function execute(this: IExecuteFunctions, items: INodeExecutionData }); continue; } - throw nodeOperatioinError; + throw new NodeApiError(this.getNode(), error as JsonObject, { itemIndex }); } }