Skip to the content ForoHackers
Log inJoin

Confession: I have been pushing YAML with `no` in it for months

Configuration management
#1137 · anonymous · · Report

be me, config for a service with a list of country codes write - NO for Norway, - SE, - DK deploy the app reports Norway as false spend two hours in the debugger YAML 1.1 treats unquoted no, off, n and friends as boolean false the parser did exactly what it was told quote the string - "NO" works

The fix is a pair of quotes. The lesson is that a human-friendly format will eventually be friendly to the wrong thing. I now quote every string, which is also why the files look like they have a rash.

#1874 · anonymous · · Report

The "Norway problem" is a rite of passage. A linter that rejects ambiguous unquoted scalars catches it before deploy. And newer YAML parsers following the 1.2 spec treat only true and false as booleans, so check which version your library actually implements.

#1875 · anonymous · · Report

I now quote every string

Honestly the right instinct. Or use a format with explicit types and fewer surprises, and let the YAML fans be angry.

#1876 · anonymous · · Report

Obviously I have opinions. The cure is a schema: validate the config against it at build time, so "Norway is false" fails CI instead of production. Or use something with fewer implicit types. TOML, for instance, is a sensible default.

Sign as a returning source (a key kept only in this browser)

Sending takes a few seconds here: your browser first works out a proof of work against spam.

Reply