mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 02:21:13 +00:00
fix(core): Handle null workflow settings in toSaveSettings (#17972)
This commit is contained in:
@@ -153,3 +153,21 @@ describe('execution progress', () => {
|
|||||||
expect(_saveSettings.progress).toBe(false);
|
expect(_saveSettings.progress).toBe(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('null workflow settings', () => {
|
||||||
|
it('should handle null workflow settings without throwing', () => {
|
||||||
|
expect(() => toSaveSettings(null)).not.toThrow();
|
||||||
|
|
||||||
|
// Should use defaults from config when settings are null
|
||||||
|
config.set('executions.saveDataOnError', 'all');
|
||||||
|
config.set('executions.saveDataOnSuccess', 'all');
|
||||||
|
config.set('executions.saveDataManualExecutions', true);
|
||||||
|
config.set('executions.saveExecutionProgress', true);
|
||||||
|
|
||||||
|
const settingsWithNull = toSaveSettings(null);
|
||||||
|
expect(settingsWithNull.error).toBe(true);
|
||||||
|
expect(settingsWithNull.success).toBe(true);
|
||||||
|
expect(settingsWithNull.manual).toBe(true);
|
||||||
|
expect(settingsWithNull.progress).toBe(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|||||||
@@ -17,7 +17,9 @@ export type ExecutionSaveSettings = {
|
|||||||
* - `manual`: Whether to save successful or failed manual executions.
|
* - `manual`: Whether to save successful or failed manual executions.
|
||||||
* - `progress`: Whether to save execution progress, i.e. after each node's execution.
|
* - `progress`: Whether to save execution progress, i.e. after each node's execution.
|
||||||
*/
|
*/
|
||||||
export function toSaveSettings(workflowSettings: IWorkflowSettings = {}): ExecutionSaveSettings {
|
export function toSaveSettings(
|
||||||
|
workflowSettings: IWorkflowSettings | null = {},
|
||||||
|
): ExecutionSaveSettings {
|
||||||
const DEFAULTS = {
|
const DEFAULTS = {
|
||||||
ERROR: config.getEnv('executions.saveDataOnError'),
|
ERROR: config.getEnv('executions.saveDataOnError'),
|
||||||
SUCCESS: config.getEnv('executions.saveDataOnSuccess'),
|
SUCCESS: config.getEnv('executions.saveDataOnSuccess'),
|
||||||
@@ -30,7 +32,7 @@ export function toSaveSettings(workflowSettings: IWorkflowSettings = {}): Execut
|
|||||||
saveDataSuccessExecution = DEFAULTS.SUCCESS,
|
saveDataSuccessExecution = DEFAULTS.SUCCESS,
|
||||||
saveManualExecutions = DEFAULTS.MANUAL,
|
saveManualExecutions = DEFAULTS.MANUAL,
|
||||||
saveExecutionProgress = DEFAULTS.PROGRESS,
|
saveExecutionProgress = DEFAULTS.PROGRESS,
|
||||||
} = workflowSettings;
|
} = workflowSettings ?? {};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
error: saveDataErrorExecution === 'DEFAULT' ? DEFAULTS.ERROR : saveDataErrorExecution === 'all',
|
error: saveDataErrorExecution === 'DEFAULT' ? DEFAULTS.ERROR : saveDataErrorExecution === 'all',
|
||||||
|
|||||||
Reference in New Issue
Block a user