mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-24 04:04:06 -08:00
fix(core): Stringify all Luxon DateTimes in cleanupParameterData (#8959)
This commit is contained in:
parent
0e4216d7af
commit
1fb0dd4f1c
|
@ -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 {
|
||||
|
|
|
@ -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');
|
||||
|
|
Loading…
Reference in a new issue