diff --git a/NEWS b/NEWS index 28c2a07da..dd9c7a168 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,6 @@ +1.3.7.dev0 + * #196: Fix for unclear error message for invalid YAML merge include. + 1.3.6 * #53: Log to syslog in addition to existing console logging. Add --syslog-verbosity flag to customize the log level. See the documentation for more information: diff --git a/borgmatic/config/load.py b/borgmatic/config/load.py index 8339dfb1d..b2c2e272f 100644 --- a/borgmatic/config/load.py +++ b/borgmatic/config/load.py @@ -54,9 +54,7 @@ class Include_constructor(ruamel.yaml.SafeConstructor): for index, (key_node, value_node) in enumerate(node.value): if key_node.tag == u'tag:yaml.org,2002:merge' and value_node.tag == '!include': - included_value = representer.represent_mapping( - tag='tag:yaml.org,2002:map', mapping=self.construct_object(value_node) - ) + included_value = representer.represent_data(self.construct_object(value_node)) node.value[index] = (key_node, included_value) super(Include_constructor, self).flatten_mapping(node) diff --git a/docs/how-to/make-per-application-backups.md b/docs/how-to/make-per-application-backups.md index 08a2ad000..0333c3392 100644 --- a/docs/how-to/make-per-application-backups.md +++ b/docs/how-to/make-per-application-backups.md @@ -105,6 +105,10 @@ include, the local file's option takes precedent. And note that this is a shallow merge rather than a deep merge, so the merging does not descend into nested values. +Note that this `<<` include merging syntax is only for merging in mappings +(keys/values). If you'd like to include other types like scalars or lists +directly, please see the section above about standard includes. + ## Related documentation diff --git a/setup.py b/setup.py index a47125d49..a47e1487b 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,6 @@ from setuptools import find_packages, setup -VERSION = '1.3.6' +VERSION = '1.3.7.dev0' setup( diff --git a/tests/integration/config/test_load.py b/tests/integration/config/test_load.py index bcaae59a5..521e92d3c 100644 --- a/tests/integration/config/test_load.py +++ b/tests/integration/config/test_load.py @@ -1,5 +1,7 @@ import sys +import pytest +import ruamel.yaml from flexmock import flexmock from borgmatic.config import load as module @@ -38,3 +40,23 @@ def test_load_configuration_merges_include(): ) assert module.load_configuration('config.yaml') == {'foo': 'override', 'baz': 'quux'} + + +def test_load_configuration_does_not_merge_include_list(): + builtins = flexmock(sys.modules['builtins']) + builtins.should_receive('open').with_args('include.yaml').and_return( + ''' + - one + - two + ''' + ) + builtins.should_receive('open').with_args('config.yaml').and_return( + ''' + foo: bar + repositories: + <<: !include include.yaml + ''' + ) + + with pytest.raises(ruamel.yaml.error.YAMLError): + assert module.load_configuration('config.yaml')