Poor error reporting for bad YAML includes #196

Closed
opened 2019-06-16 22:52:09 +00:00 by elho · 4 comments

Given these config files that wrongly try a (dictionary) YAML merge include on a item that is a list...

bad.yaml:

location:
  source_directories:
    - /test

  repositories:
    <<: !include ./repositories.yaml

repositories.yaml:

- foo@bar:qux
- foo@baz:quux

Both borgmatic and validate-borgmatic-config give this error message:

bad.yaml: Error parsing configuration file
too many values to unpack (expected 2)

Unlike for other errors, theer's no indication what or where in the file the error is.

Given these config files that wrongly try a (dictionary) YAML merge include on a item that is a list... `bad.yaml`: ``` location: source_directories: - /test repositories: <<: !include ./repositories.yaml ``` `repositories.yaml`: ``` - foo@bar:qux - foo@baz:quux ``` Both `borgmatic` and `validate-borgmatic-config` give this error message: ``` bad.yaml: Error parsing configuration file too many values to unpack (expected 2) ``` Unlike for other errors, theer's no indication what or where in the file the error is.
witten added the
bug
label 2019-06-16 23:24:21 +00:00
Owner

Thanks for reporting. This error is coming from deep within ruamel.yaml, but we may be able to do something about it.

Thanks for reporting. This error is coming from deep within `ruamel.yaml`, but we may be able to do something about it.
Owner

Well, I've got a potential fix (needs more testing) that results in the following better error message:

bad.yaml: Error parsing configuration file
An error occurred while parsing a configuration file at bad.yaml:
while constructing a mapping
  in "bad.yaml", line 6, column 5
expected a mapping for merging, but found scalar
Well, I've got a potential fix (needs more testing) that results in the following better error message: ```console bad.yaml: Error parsing configuration file An error occurred while parsing a configuration file at bad.yaml: while constructing a mapping in "bad.yaml", line 6, column 5 expected a mapping for merging, but found scalar ```
Owner

Fixed in master. The fix will go out as part of the next release. I do really appreciate tickets on these sorts of things, as it helps me find and fix things that are unclear or just plain wrong that I may not know about.

Fixed in master. The fix will go out as part of the next release. I do really appreciate tickets on these sorts of things, as it helps me find and fix things that are unclear or just plain wrong that I may not know about.
Owner

Just released as part of borgmatic 1.3.7.

Just released as part of borgmatic 1.3.7.
Sign in to join this conversation.
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: borgmatic-collective/borgmatic#196
No description provided.