fix(core): Handle null workflow settings in toSaveSettings (#17972)

This commit is contained in:
Eugene
2025-08-04 17:12:07 +02:00
committed by GitHub
parent 381c146dd4
commit 642e68e345
2 changed files with 22 additions and 2 deletions

View File

@@ -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);
});
});

View File

@@ -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',