3 ms·
Looking back to the last decade, I cannot remember a single project I worked in that relied on YAML that didn't have at least one incident from its users or dev
by pjbk 6y ago
Looking back to the last decade, I cannot remember a single project I worked in that relied on YAML that didn't have at least one incident from its users or developers dealing with the files and messing up. Just some months ago a team I was working with lost almost a day on a misbehaving software module. After serious detective work it all came down to whitespace in a YAML configuration file.
I remember being pretty excited when I discovered YAML and even pushed its use in some projects trying to avoid the verbosity of XML. These days I will never trade accuracy for conciseness, in particular if its form relies on whitespace and there is not enough redundancy in the specs for consistency checks. Yes, syntax matters.
- deleted 6y ago[deleted]
- ars 6y agoThe biggest problem I find with YML is that whitespace matters, but merging tools usually are set to ignore whitespace. So git merge will say "no merge conflicts", but actually there were whitespace changes.
- Anka33 6y agoXML master race!
- brown9-2 6y agoI’m curious, do you recall what the specifics of the whitespace change were?
- pjbk 6y agoYes. It was an indentation issue. It turned that the parent list accepted an item with the same id, so it was a valid statement and the full thing seemed OK. However the data ended up missing from where it was supposed to be.
- andrenth 6y agoBeing a superset of JSON, YAML allows you to use braces for maps and square brackets for arrays instead of relying on indentation. You can still omit quotes around strings, use comments and add trailing commas after the last element of collections. A configuration file written in that style is actually pretty nice. I’ve never understood why people don’t use this.
- smitty1e 6y agoBut you can't put comments in JSON. But you can write Python (or pretty much any other tool) and have it emitted as JSON.
- andrenth 6y agoI think you misunderstood. What I meant is that you can put comments in YAML but use JSON-like braces instead of relying on indentation.
- balfirevic 6y agoExcept for omitting quotes around strings, that sounds very similar to json5 [0]. [0] - https://json5.org/ https://json5.org/
- predakanga 6y agoHave you considered validating your YAML against a schema? JSON Schema[0] can do the trick, and has decent editor support[1]. It's not a panacea, but it can help avoid those long debugging sessions. [0]: https://json-schema-everywhere.github.io/yaml https://json-schema-everywhere.github.io/yaml [1]: https://marketplace.visualstudio.com/items?itemName=redhat.vscode-yaml https://marketplace.visualstudio.com/items?itemName=redhat.v...
- pjbk 6y agoThanks for the suggestion. Last time I had to use YAML I used StrictYAML instead which gave me more peace of mind. I knew that there were schema tools around, however I just put more checks in the validator to avoid adding extra dependencies. Next time I will definitely look into those.