fix(Google Cloud Firestore Node): Fix empty array serialization in jsonToDocument (#28213)
Some checks failed
CI: Master (Build, Test, Lint) / Build for Github Cache (push) Has been cancelled
CI: Master (Build, Test, Lint) / Unit tests (push) Has been cancelled
CI: Master (Build, Test, Lint) / Lint (push) Has been cancelled
CI: Master (Build, Test, Lint) / Performance (push) Has been cancelled
CI: Master (Build, Test, Lint) / Notify Slack on failure (push) Has been cancelled

Co-authored-by: RomanDavydchuk <roman.davydchuk@n8n.io>
This commit is contained in:
James Campbell 2026-04-18 09:48:45 -04:00 committed by GitHub
parent f1dab3e295
commit 7094395cef
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 1 deletions

View file

@ -90,7 +90,7 @@ export function jsonToDocument(value: string | number | IDataObject | IDataObjec
return { booleanValue: value };
} else if (value === null) {
return { nullValue: null };
} else if (value !== '' && !isNaN(value as number)) {
} else if (value !== '' && typeof value !== 'object' && !isNaN(value as number)) {
if (value.toString().indexOf('.') !== -1) {
return { doubleValue: value };
} else {

View file

@ -344,6 +344,10 @@ describe('GoogleFirebaseCloudFirestore > GenericFunctions', () => {
});
});
it('should convert empty arrays', () => {
expect(jsonToDocument([] as any)).toEqual({ arrayValue: { values: [] } });
});
it('should handle edge cases', () => {
expect(jsonToDocument(0)).toEqual({ integerValue: 0 });
expect(jsonToDocument(NaN as any)).toEqual({});