diff --git a/NEWS b/NEWS index 1de4156c..a3e5d83d 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,7 @@ 1.5.11.dev0 * #341: Add "temporary_directory" option for changing Borg's temporary directory. * #352: Lock down systemd security settings in sample systemd service file. + * #355: Fix traceback when a database hook value is null in a configuration file. 1.5.10 * #347: Add hooks that run for the "extract" action: "before_extract" and "after_extract". diff --git a/borgmatic/commands/borgmatic.py b/borgmatic/commands/borgmatic.py index a6df97b4..1f41f4e5 100644 --- a/borgmatic/commands/borgmatic.py +++ b/borgmatic/commands/borgmatic.py @@ -658,7 +658,9 @@ def collect_configuration_run_summary_logs(configs, arguments): if not configs: yield from make_error_log_records( - '{}: No configuration files found'.format(' '.join(arguments['global'].config_paths)) + '{}: No valid configuration files found'.format( + ' '.join(arguments['global'].config_paths) + ) ) return diff --git a/borgmatic/hooks/dispatch.py b/borgmatic/hooks/dispatch.py index 6c05cad9..6fb2c808 100644 --- a/borgmatic/hooks/dispatch.py +++ b/borgmatic/hooks/dispatch.py @@ -58,5 +58,5 @@ def call_hooks(function_name, hooks, log_prefix, hook_names, *args, **kwargs): return { hook_name: call_hook(function_name, hooks, log_prefix, hook_name, *args, **kwargs) for hook_name in hook_names - if hook_name in hooks + if hooks.get(hook_name) } diff --git a/tests/unit/hooks/test_dispatch.py b/tests/unit/hooks/test_dispatch.py index ec163d81..7224e194 100644 --- a/tests/unit/hooks/test_dispatch.py +++ b/tests/unit/hooks/test_dispatch.py @@ -58,7 +58,7 @@ def test_call_hooks_calls_each_hook_and_collects_return_values(): assert return_values == expected_return_values -def test_call_hooks_calls_skips_return_values_for_unconfigured_hooks(): +def test_call_hooks_calls_skips_return_values_for_missing_hooks(): hooks = {'super_hook': flexmock()} expected_return_values = {'super_hook': flexmock()} flexmock(module).should_receive('call_hook').and_return(expected_return_values['super_hook']) @@ -66,3 +66,13 @@ def test_call_hooks_calls_skips_return_values_for_unconfigured_hooks(): return_values = module.call_hooks('do_stuff', hooks, 'prefix', ('super_hook', 'other_hook'), 55) assert return_values == expected_return_values + + +def test_call_hooks_calls_skips_return_values_for_null_hooks(): + hooks = {'super_hook': flexmock(), 'other_hook': None} + expected_return_values = {'super_hook': flexmock()} + flexmock(module).should_receive('call_hook').and_return(expected_return_values['super_hook']) + + return_values = module.call_hooks('do_stuff', hooks, 'prefix', ('super_hook', 'other_hook'), 55) + + assert return_values == expected_return_values