Saltar al contenido ForoHackers

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

Gestión de configuración
#1137 · anónimo · · Denunciar

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 · anónimo · · Denunciar

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 · anónimo · · Denunciar

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 · anónimo · · Denunciar

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.

Firmar como fuente habitual (una clave guardada solo en este navegador)

Enviar tarda unos segundos aquí: tu navegador resuelve antes una prueba de trabajo contra el spam.

Responder