diff --git a/NEWS b/NEWS index abafbda0..9aafe7ec 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,5 @@ 1.6.1.dev0 + * #528: Improve the error message when a configuration override contains an invalid value. * #532: When a configuration include is a relative path, load it from either the current working directory or from the directory containing the file doing the including. (Previously, only the working directory was used.) diff --git a/borgmatic/config/override.py b/borgmatic/config/override.py index 4557e29b..8596cb3e 100644 --- a/borgmatic/config/override.py +++ b/borgmatic/config/override.py @@ -52,16 +52,20 @@ def parse_overrides(raw_overrides): if not raw_overrides: return () - try: - return tuple( - (tuple(raw_keys.split('.')), convert_value_type(value)) - for raw_override in raw_overrides - for raw_keys, value in (raw_override.split('=', 1),) - ) - except ValueError: - raise ValueError('Invalid override. Make sure you use the form: SECTION.OPTION=VALUE') - except ruamel.yaml.error.YAMLError as error: - raise ValueError(f'Invalid override value: {error}') + parsed_overrides = [] + + for raw_override in raw_overrides: + try: + raw_keys, value = raw_override.split('=', 1) + parsed_overrides.append((tuple(raw_keys.split('.')), convert_value_type(value),)) + except ValueError: + raise ValueError( + f"Invalid override '{raw_override}'. Make sure you use the form: SECTION.OPTION=VALUE" + ) + except ruamel.yaml.error.YAMLError as error: + raise ValueError(f"Invalid override '{raw_override}': {error.problem}") + + return tuple(parsed_overrides) def apply_overrides(config, raw_overrides): diff --git a/docs/how-to/make-per-application-backups.md b/docs/how-to/make-per-application-backups.md index eeb76ad5..9ea496c1 100644 --- a/docs/how-to/make-per-application-backups.md +++ b/docs/how-to/make-per-application-backups.md @@ -176,7 +176,14 @@ borgmatic create --override location.repositories=[test1.borg,test2.borg] Or even a single list element: ```bash -borgmatic create --override location.repositories=[/root/test1.borg] +borgmatic create --override location.repositories=[/root/test.borg] +``` + +If your override value contains special YAML characters like colons, then +you'll need quotes for it to parse correctly: + +```bash +borgmatic create --override location.repositories="['user@server:test.borg']" ``` There is not currently a way to override a single element of a list without