mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-16 17:46:45 +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);
|
||||
});
|
||||
});
|
||||
|
||||
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.
|
||||
* - `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 = {
|
||||
ERROR: config.getEnv('executions.saveDataOnError'),
|
||||
SUCCESS: config.getEnv('executions.saveDataOnSuccess'),
|
||||
@@ -30,7 +32,7 @@ export function toSaveSettings(workflowSettings: IWorkflowSettings = {}): Execut
|
||||
saveDataSuccessExecution = DEFAULTS.SUCCESS,
|
||||
saveManualExecutions = DEFAULTS.MANUAL,
|
||||
saveExecutionProgress = DEFAULTS.PROGRESS,
|
||||
} = workflowSettings;
|
||||
} = workflowSettings ?? {};
|
||||
|
||||
return {
|
||||
error: saveDataErrorExecution === 'DEFAULT' ? DEFAULTS.ERROR : saveDataErrorExecution === 'all',
|
||||
|
||||
Reference in New Issue
Block a user