webhook
webhook copied to clipboard
Undocumented YAML support breaks JSON style comments in config file
I was writing a config file and was getting an error message
couldn't load hooks from file! error converting YAML to JSON: yaml: line 7: did not find expected ',' or ']'
I had commented out a line for testing, but it turns out the //
comment was breaking it. Noticing the message about YAML, I tried using #
to comment it out instead and everything worked correctly.
It would be nice if the support for YAML was documented (possibly with some examples) because it is much easier to use for manually written configs. It would also be nice if both styles of comments were supported.
Ugh, that's why I hate magic in applications :-(
We should definitely improve YAML support, documentation, and make it an explicit option instead of magically loading it and then falling back to JSON if it doesn't work...
Thanks.
I found this issue after getting a JSON parser error even though I provided a YAML config.
Isn't YAML basically a superset of JSON, so using only a YAML parser would work just as well for both formats? It might depend on the parser but it might be worth a try ;)
Update: it turns out I had errors in my YAML syntax. Always use a linter, kids!
Isn't YAML basically a superset of JSON...
For the record, YAML is not a superset of JSON.
Per https://yaml.org/spec/1.2/spec.html
The primary objective of this revision is to bring YAML into compliance with JSON as an official subset.