YAML is seeing an increase in usage for configuration files. While this is good, there are a few things to watch out for. I will add to this list as I come across, or hear of, more things to watch out for.
Indentation Matters (A LOT)
Much like Python, indentation matters a lot in YAML. Best practice is to use spaces and not tabs, which to me is more of a pain than it needs to be. That being said, pay close attention to the number of spaces you are using, being inconsistent by just one space. I found this out the hard way when working on a config file. I had one section that was off by just one space and kept getting an error that “yaml did not find the expected key”. Took me over an hour to track down that little oops. (<rant>Tabs would have made it easier to see where the problem was, but I was following ‘best practices’ </endrant>)
Make Sure You Close Braces ({}), Brackets ([]) and Parenthesis ()
I stumbled across this gotcha on another while tracking down the space issue mentioned above. And I’ve been bitten by this a few times when writing scripts. Just make sure you close what you open.