yaml ScannerError: mapping values are not allowed here
aruetten opened this issue · comments
Hi,
having an issue with DogPush:
Just did an initial dump of my monitors followed directly by a diff and get a failing dogpush while reading the YAML just after it was created by himself. No manual changes to the file:
$ rm my_monitors.yaml
$ dogpush -c ./config.yaml diff > ./my_monitors.yaml
$ dogpush diff
Traceback (most recent call last):
File "/home/some/path/virt_envs/dogpush/bin/dogpush", line 5, in <module>
dogpush.main()
File "/home/some/path/virt_envs/dogpush/local/lib/python2.7/site-packages/dogpush/dogpush.py", line 422, in main
args.command(args)
File "/home/some/path/virt_envs/dogpush/local/lib/python2.7/site-packages/dogpush/dogpush.py", line 316, in command_diff
local_monitors = get_local_monitors()
File "/home/some/path/virt_envs/dogpush/local/lib/python2.7/site-packages/dogpush/dogpush.py", line 186, in get_local_monitors
r = yaml.safe_load(f)
File "/home/some/path/virt_envs/dogpush/local/lib/python2.7/site-packages/yaml/__init__.py", line 93, in safe_load
return load(stream, SafeLoader)
File "/home/some/path/virt_envs/dogpush/local/lib/python2.7/site-packages/yaml/__init__.py", line 71, in load
return loader.get_single_data()
File "/home/some/path/virt_envs/dogpush/local/lib/python2.7/site-packages/yaml/constructor.py", line 37, in get_single_data
node = self.get_single_node()
File "/home/some/path/virt_envs/dogpush/local/lib/python2.7/site-packages/yaml/composer.py", line 36, in get_single_node
document = self.compose_document()
File "/home/some/path/virt_envs/dogpush/local/lib/python2.7/site-packages/yaml/composer.py", line 58, in compose_document
self.get_event()
File "/home/some/path/virt_envs/dogpush/local/lib/python2.7/site-packages/yaml/parser.py", line 118, in get_event
self.current_event = self.state()
File "/home/some/path/virt_envs/dogpush/local/lib/python2.7/site-packages/yaml/parser.py", line 193, in parse_document_end
token = self.peek_token()
File "/home/some/path/virt_envs/dogpush/local/lib/python2.7/site-packages/yaml/scanner.py", line 128, in peek_token
self.fetch_more_tokens()
File "/home/some/path/virt_envs/dogpush/local/lib/python2.7/site-packages/yaml/scanner.py", line 220, in fetch_more_tokens
return self.fetch_value()
File "/home/some/path/virt_envs/dogpush/local/lib/python2.7/site-packages/yaml/scanner.py", line 576, in fetch_value
self.get_mark())
yaml.scanner.ScannerError: mapping values are not allowed here
in "/home/some/path/vcs/git/smt-dogpush/my_monitors.yaml", line 7, column 10
Versions:
$ pip freeze
certifi==2018.1.18
chardet==3.0.4
datadog==0.20.0
decorator==4.2.1
DogPush==0.3.4
idna==2.6
pkg-resources==0.0.0
pytz==2018.4
PyYAML==3.12
requests==2.18.4
simplejson==3.13.2
urllib3==1.22
$ cat -n ./my_monitors.yaml
1 ------------------------------------------------------------
2 UNTRACKED MONITORS. These monitors are only in datadog
3 and needed to be MANUALLY added to a local file or removed
4 from datadog.
5 ------------------------------------------------------------
6
7 - message: "{{#is_alert}}\nFoo demand https is not healthy\n@foo@company.com\
8 \ @slack-foo-operations \n{{/is_alert}} \n\n{{#is_no_data}}\nNO DATA \n@foo@company.com\
9 \ @slack-foo-operations \n{{/is_no_data}}\n\n{{#is_recovery}}\nRecovered \n@foo@company.com\
10 \ @slack-foo-operations \n{{/is_recovery}}"
11 multi: true
12 name: Foo Demand https health
[...]
@aruetten It looks like you faced two issues
First of all you need a DogPush
version which includes #23 (Use safe dump when printing yaml)
Second it looks like that your my_monitors.yaml
has a wrong data format, this is because you created this file with dogpush diff
instead of dogpush init
This order gives you the expected outcome
$ dogpush -c ./config.yaml init > ./my_monitors.yaml
$ dogpush diff
I personally don't have an idea but maybe @nandrienko because he merged the recent pull requests