Skip to content

Commit 3a0d2d9

Browse files
committed
fix(Drive): Add error handling for folder ID in file download operation
1 parent 5ea4be4 commit 3a0d2d9

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

packages/nodes-base/nodes/Google/Drive/v2/actions/file/download.operation.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@ import type {
55
INodeExecutionData,
66
INodeProperties,
77
} from 'n8n-workflow';
8+
import { NodeOperationError } from 'n8n-workflow';
89

910
import { updateDisplayOptions } from '@utils/utilities';
1011

1112
import { googleApiRequest } from '../../transport';
1213
import { fileRLC } from '../common.descriptions';
14+
import { DRIVE } from '../../helpers/interfaces';
1315

1416
const properties: INodeProperties[] = [
1517
{
@@ -205,6 +207,15 @@ export async function execute(
205207
{},
206208
{ fields: 'mimeType,name', supportsTeamDrives: true, supportsAllDrives: true },
207209
);
210+
211+
// If user accidentally provides a folder ID, throw a clear, actionable error
212+
if (file?.mimeType === DRIVE.FOLDER) {
213+
throw new NodeOperationError(
214+
this.getNode(),
215+
'The provided ID refers to a folder. Please provide a file ID to download.',
216+
{ itemIndex: i },
217+
);
218+
}
208219
let response;
209220

210221
if (file.mimeType?.includes('vnd.google-apps')) {

0 commit comments

Comments
 (0)