Skip to content

Commit

Permalink
fix(Google Sheets Node): Check for null before destructuring (#7729)
Browse files Browse the repository at this point in the history
  • Loading branch information
ivov authored Nov 16, 2023
1 parent d39bb25 commit 5d4a52d
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions packages/nodes-base/nodes/Google/Sheet/v2/methods/loadOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ import { getSpreadsheetId } from '../helpers/GoogleSheets.utils';
import type { ResourceLocator } from '../helpers/GoogleSheets.types';

export async function getSheets(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
const { mode, value } = this.getNodeParameter('documentId', 0) as IDataObject;
const documentId = this.getNodeParameter('documentId', 0) as IDataObject | null;

if (!documentId) return [];

const { mode, value } = documentId;

const spreadsheetId = getSpreadsheetId(this.getNode(), mode as ResourceLocator, value as string);

const sheet = new GoogleSheet(spreadsheetId, this);
Expand Down Expand Up @@ -33,7 +38,12 @@ export async function getSheets(this: ILoadOptionsFunctions): Promise<INodePrope
export async function getSheetHeaderRow(
this: ILoadOptionsFunctions,
): Promise<INodePropertyOptions[]> {
const { mode, value } = this.getNodeParameter('documentId', 0) as IDataObject;
const documentId = this.getNodeParameter('documentId', 0) as IDataObject | null;

if (!documentId) return [];

const { mode, value } = documentId;

const spreadsheetId = getSpreadsheetId(this.getNode(), mode as ResourceLocator, value as string);

const sheet = new GoogleSheet(spreadsheetId, this);
Expand Down

0 comments on commit 5d4a52d

Please sign in to comment.