fix(Google Sheets Node): Handle undefined lookup values in lookupValues (#31055)

This commit is contained in:
Michael Kret 2026-05-25 14:21:46 +03:00 committed by GitHub
parent 35791f7b27
commit 7348f928c8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 35 additions and 3 deletions

View File

@ -239,6 +239,38 @@ describe('GoogleSheet', () => {
expect(result).toEqual([{ name: 'John', age: '30', city: 'NY' }]);
});
it('should ignore undefined lookup values without throwing (OR)', async () => {
const lookupValues = [{ lookupColumn: 'age', lookupValue: undefined }];
const result = await googleSheet.lookupValues({
inputData,
keyRowIndex: 0,
dataStartRowIndex: 1,
lookupValues,
returnAllMatches: true,
combineFilters: 'OR',
nodeVersion: 4.5,
});
expect(result).toEqual([]);
});
it('should ignore undefined lookup values without throwing (AND)', async () => {
const lookupValues = [{ lookupColumn: 'age', lookupValue: undefined }];
const result = await googleSheet.lookupValues({
inputData,
keyRowIndex: 0,
dataStartRowIndex: 1,
lookupValues,
returnAllMatches: true,
combineFilters: 'AND',
nodeVersion: 4.5,
});
expect(result).toEqual([]);
});
it('should throw error for invalid key row', async () => {
const lookupValues = [{ lookupColumn: 'age', lookupValue: '30' }];

View File

@ -737,7 +737,7 @@ export class GoogleSheet {
for (rowIndex = dataStartRowIndex; rowIndex < inputData.length; rowIndex++) {
if (
inputData[rowIndex][returnColumnIndex]?.toString() ===
lookupValue.lookupValue.toString()
lookupValue.lookupValue?.toString()
) {
if (addedRows.indexOf(rowIndex) === -1) {
returnData.push(inputData[rowIndex]);
@ -769,7 +769,7 @@ export class GoogleSheet {
if (
inputData[rowIndex][returnColumnIndex]?.toString() !==
lookupValue.lookupValue.toString()
lookupValue.lookupValue?.toString()
) {
allMatch = false;
break;

View File

@ -18,7 +18,7 @@ export interface ISheetUpdateData {
export interface ILookupValues {
lookupColumn: string;
lookupValue: string;
lookupValue: string | number | boolean | null | undefined;
}
export interface IToDeleteRange {