mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 01:56:46 +00:00
fix(core): Improve handling of invalid objects in cleanupParameterData (no-chanhelog) (#8910)
This commit is contained in:
committed by
GitHub
parent
669bd830e9
commit
33ab781aef
@@ -1,4 +1,5 @@
|
||||
import {
|
||||
cleanupParameterData,
|
||||
copyInputItems,
|
||||
getBinaryDataBuffer,
|
||||
parseIncomingMessage,
|
||||
@@ -7,6 +8,7 @@ import {
|
||||
removeEmptyBody,
|
||||
setBinaryDataBuffer,
|
||||
} from '@/NodeExecuteFunctions';
|
||||
import { DateTime } from 'luxon';
|
||||
import { mkdtempSync, readFileSync } from 'fs';
|
||||
import type { IncomingMessage } from 'http';
|
||||
import { mock } from 'jest-mock-extended';
|
||||
@@ -18,6 +20,7 @@ import type {
|
||||
IRequestOptions,
|
||||
ITaskDataConnections,
|
||||
IWorkflowExecuteAdditionalData,
|
||||
NodeParameterValue,
|
||||
Workflow,
|
||||
WorkflowHooks,
|
||||
} from 'n8n-workflow';
|
||||
@@ -414,6 +417,29 @@ describe('NodeExecuteFunctions', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('cleanupParameterData', () => {
|
||||
it('should stringify Luxon dates in-place', () => {
|
||||
const input = { x: 1, y: DateTime.now() as unknown as NodeParameterValue };
|
||||
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');
|
||||
cleanupParameterData(input);
|
||||
expect(typeof input.y).toBe('object');
|
||||
});
|
||||
|
||||
it('should handle objects without a constructor', () => {
|
||||
const input = { x: 1, y: { constructor: undefined } as unknown as NodeParameterValue };
|
||||
expect(typeof input.y).toBe('object');
|
||||
cleanupParameterData(input);
|
||||
expect(typeof input.y).toBe('object');
|
||||
});
|
||||
});
|
||||
|
||||
describe('copyInputItems', () => {
|
||||
it('should pick only selected properties', () => {
|
||||
const output = copyInputItems(
|
||||
|
||||
Reference in New Issue
Block a user