diff --git a/packages/core/src/NodeExecuteFunctions.ts b/packages/core/src/NodeExecuteFunctions.ts index ca1ea6028bae3..cecabed23957a 100644 --- a/packages/core/src/NodeExecuteFunctions.ts +++ b/packages/core/src/NodeExecuteFunctions.ts @@ -2112,7 +2112,7 @@ export function cleanupParameterData(inputData: NodeParameterValueType): void { (Object.keys(inputData) as Key[]).forEach((key) => { const value = inputData[key]; if (typeof value === 'object') { - if (value instanceof DateTime) { + if (DateTime.isDateTime(value)) { // Is a special luxon date so convert to string inputData[key] = value.toString(); } else { diff --git a/packages/core/test/NodeExecuteFunctions.test.ts b/packages/core/test/NodeExecuteFunctions.test.ts index a644cd6793ec5..92f23782189d4 100644 --- a/packages/core/test/NodeExecuteFunctions.test.ts +++ b/packages/core/test/NodeExecuteFunctions.test.ts @@ -30,6 +30,7 @@ import { tmpdir } from 'os'; import { join } from 'path'; import Container from 'typedi'; import type { Agent } from 'https'; +import toPlainObject from 'lodash/toPlainObject'; const temporaryDir = mkdtempSync(join(tmpdir(), 'n8n')); @@ -425,6 +426,16 @@ describe('NodeExecuteFunctions', () => { expect(typeof input.y).toBe('string'); }); + it('should stringify plain Luxon dates in-place', () => { + const input = { + x: 1, + y: toPlainObject(DateTime.now()), + }; + expect(typeof input.y).toBe('object'); + cleanupParameterData(input); + expect(typeof input.y).toBe('string'); + }); + it('should handle objects with nameless constructors', () => { const input = { x: 1, y: { constructor: {} } as NodeParameterValue }; expect(typeof input.y).toBe('object');