TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

YAML: The Norway Problem (2022)

222 pointsby carlos-menezesabout 1 month ago

30 comments

azernikabout 1 month ago
Even worse is the all-decimal MAC problem.<p>Some genius decided that, to make time input convenient, YAML would parse HH:MM:SS as SS + 60×MM + 60×60×HH. So you could enter 1:23:45 and it would give you the correct number of seconds in 1 hour, 23 minutes, and 45 seconds.<p>They neglected to put a maximum on the number of such sexagesimal places, so if you put, say, six numbers separated by colons like this, it would be parsed as a very large integer.<p>Imagine my surprise when, while working at a networking company, we had some devices which failed to configure their MAC addresses in YAML! After this YAML config file had been working for literal years! (I believe this was via netplan? It&#x27;s been like a decade, I don&#x27;t remember.)<p>Turns out, if an unquoted MAC address had even a single non-decimal hex digit, it would do what we expected (parse as a string). This is not only by FAR the more common case, but also we had an A in our vendor prefix, so we never ran into this &quot;feature&quot; during initial development.<p>Then one day we ran out of MAC addresses and got a new vendor prefix. This time it didn&#x27;t have any letters in it. Hilarity ensued.<p>(This behavior has thankfully been removed in more recent YAML standards.)
weinzierlabout 1 month ago
Perl has a <i>Poland Problem</i>. The customary file extension for Perl files is *.pl. This worked well until Apache introduced content negotiation and the convention to add a language code as file extension. It had index.html.en, index.html.de, for example.<p>index.html.pl is where the problem started and the reason why the officially recommended file extension for Perl files used to be (still is?) *.plx.<p>I don&#x27;t have the Camel book at hand, but Randal Schwartz&#x27;s <i>Learning Perl</i> 5th edition says:<p><i>&quot;Perl doesn&#x27;t require any special kind of filename or extension, and it&#x27;s better not to use an extension at all. But some systems may require an extension like plx (meaning PerL eXecutable); see your system&#x27;s release notes for more information.&quot;</i>
评论 #43671712 未加载
评论 #43672758 未加载
gnabgibabout 1 month ago
Related<p><i>The YAML document from hell</i> (566 points, 2023, 353 comments) <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=34351503">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=34351503</a><p><i>That&#x27;s a Lot of YAML</i> (429 points, 2023, 478 comments) <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=37687060">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=37687060</a><p><i>No YAML</i> (Same as above) (152 points, 2021, 149 comments) <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=29019361">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=29019361</a>
评论 #43670300 未加载
pkkmabout 1 month ago
Programming with string templates, in a highly complex and footgun-rich markup language, is one of the things I find most offputting about the DevOps ecosystem.
评论 #43672145 未加载
评论 #43673882 未加载
anvandareabout 1 month ago
&quot;The limits of my keyboard mean the limits of my programming language.&quot;<p>If only they had had ⊥ and ⊤ somewhere on their keys to work with Booleans directly while designing the languages. In another branch of history, perchance.[1]<p>[1] <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;APL_(programming_language)#&#x2F;media&#x2F;File:APL-keybd2.svg" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;APL_(programming_language)#&#x2F;me...</a>
评论 #43672175 未加载
评论 #43673071 未加载
whacko_quackoabout 1 month ago
Pandas has a Nigeria problem, where NA -&gt; NaN.<p>It&#x27;s not that bad, because you can explicitly turn that behavior off, but ask me how I know =(
评论 #43672342 未加载
评论 #43672147 未加载
alkonautabout 1 month ago
Always quote all yaml strings. If you have a yaml file that has something that isn&#x27;t a simple value (number, boolean) such as for example a date, time, ip-address, mac address, country code, phone number, server name, configuration name, etc. etc. then you are asking for trouble. Just DON&#x27;T DO THAT. It&#x27;s pretty simple.<p>&quot;Yeah but it&#x27;s so convenient&quot;<p>&quot;Yeah but the benefit of yaml is that you don&#x27;t need quotes everywhere so that it&#x27;s more human readable&quot;<p>DON&#x27;T
评论 #43673362 未加载
ashishbabout 1 month ago
How often do people even encounter this issue? I have been using YAML for 5+ years and have never had it before. Further, I use `yamllint` which points this out as a lint issue &quot;truthy value should be one of [false, true]&quot;.
评论 #43670533 未加载
评论 #43670378 未加载
评论 #43669250 未加载
评论 #43672163 未加载
评论 #43669965 未加载
评论 #43670480 未加载
评论 #43670466 未加载
评论 #43673248 未加载
评论 #43671320 未加载
quechimbaabout 1 month ago
We had this issue many years ago when people from Norway couldn&#x27;t sign up. Took us a while to figure out
评论 #43670201 未加载
评论 #43669938 未加载
评论 #43670077 未加载
评论 #43669862 未加载
评论 #43669552 未加载
umanwizardabout 1 month ago
“Be liberal in what you accept” rears its ugly head once more.
评论 #43669792 未加载
评论 #43673521 未加载
评论 #43670695 未加载
xelxebarabout 1 month ago
This has been fixed since 2009 with YAML 1.2. The problem is that everyone uses libyaml (_e.g._ PyYAML _etc._) which is stuck on 1.1 for reasons.<p>The 1.2 spec just treats all scalar types as opaque strings, along with a configurable mechanism[0] for auto-converting non-quoted scalars if you so please.<p>As such, I really don&#x27;t quite grok why upstream libraries haven&#x27;t moved to YAML 1.2. Would love to hear details from anyone with more info.<p>[0]:<a href="https:&#x2F;&#x2F;yaml.org&#x2F;spec&#x2F;1.2.2&#x2F;#chapter-10-recommended-schemas" rel="nofollow">https:&#x2F;&#x2F;yaml.org&#x2F;spec&#x2F;1.2.2&#x2F;#chapter-10-recommended-schemas</a>
评论 #43670847 未加载
评论 #43671894 未加载
评论 #43672348 未加载
nnurmanovabout 1 month ago
Another solution is to change the country name:)
评论 #43670237 未加载
评论 #43670971 未加载
hgomersallabout 1 month ago
IMO the proposed solution of StrictYAML + schema is the right one here and what we use extensively for human readable configs. StrictYAML (linked to in the post) is essentially a string-type-only restriction of YAML, so you impose your type coercion on the parsed data structure.
评论 #43671486 未加载
raffraffraffabout 1 month ago
Why not just use quotes all the time for strings?
评论 #43671450 未加载
评论 #43670571 未加载
评论 #43670537 未加载
firesteelrainabout 1 month ago
This problem occurs because pyyaml load() uses the full YAML 1.1 schema. There is another function BaseLoader that will interpret everything as a string which is the workaround that the article suggests. Just another way to achieve it.<p>It’s a bit of a sore spot in the YAML community as to why PyYAML can’t &#x2F; won’t support YAML 1.2. It was in maintenance mode for a while. YAML 1.2 also introduced breaking changes.<p>From a SO comment: “ As long as you&#x27;re okay with the YAML 1.1 standard, PyYAML is still perfectly fine, secure, etc. If you want to support the YAML 1.2 spec (released in 2009), you can use ruamel.yaml, which started out as a fork of PyYAML. – CrazyChucky Commented Mar 26, 2023 at 20:51”<p>- <a href="https:&#x2F;&#x2F;stackoverflow.com&#x2F;q&#x2F;75850232" rel="nofollow">https:&#x2F;&#x2F;stackoverflow.com&#x2F;q&#x2F;75850232</a>
评论 #43670649 未加载
评论 #43668970 未加载
kazinatorabout 1 month ago
In Lisp, if you want to read text into symbols (e.g. file of words), you just switch to a dedicated package in which those symbols are interned. Then if NIL happens to come up, it will be a symbol named &quot;NIL&quot; in that package, unrelated to the special object.
dissentabout 1 month ago
I reckon if this is really a big concern for anybody, then they are probably writing way too much YAML to begin with. If you&#x27;re being caught out by things like this and need to debug it, then it maps very cleanly to types in most high level languages and you can generate your YAML from that instead.
评论 #43669211 未加载
评论 #43670562 未加载
thundabout 1 month ago
I like using tags and avoid any doubt<p>!!boolean<p><a href="https:&#x2F;&#x2F;dev.to&#x2F;kalkwst&#x2F;a-gentle-introduction-to-the-yaml-format-bi6#:~:text=A%20YAML%20tag%20is%20a,)%2C%20followed%20by%20a%20URI." rel="nofollow">https:&#x2F;&#x2F;dev.to&#x2F;kalkwst&#x2F;a-gentle-introduction-to-the-yaml-for...</a>
ajucabout 1 month ago
YAML is just doing too much and trying to be too clever.
cirwinabout 1 month ago
I’ve been working on <a href="https:&#x2F;&#x2F;conl.dev" rel="nofollow">https:&#x2F;&#x2F;conl.dev</a>, which fixes&#x2F;removes YAMLs problematic features.<p>Trying to find a tag-line for it I like, maybe “markdown for config”?
thyrsusabout 1 month ago
I do a lot of ansible which needs to run on multiple versions, and their yaml typing are not consistent - whenever I have a variable in a logic statement, I nearly always need to apply the &quot;| bool&quot; filter.
评论 #43673972 未加载
评论 #43669340 未加载
TZubiriabout 1 month ago
That edge case sounds like a reasonable tradeoff you would make for such a simple and readable generic data format.<p>Escaped json probably hits that sweetspot by being a bit uglier than yaml, but 100 times simpler than xml, though.
评论 #43670560 未加载
endofreachabout 1 month ago
The article mentioned people with the last name &quot;null&quot;. I never thought about that. It sounds like really fun in modern days to have that last name.
评论 #43676115 未加载
singpolyma3about 1 month ago
Quote your strings
评论 #43669471 未加载
maelitoabout 1 month ago
We should use very basic yaml parsers without these kind of functions.
praptakabout 1 month ago
Related: the YAML exponent problem[0]<p>TLDR: unquoted hex hash in YAML is fine until it happens to match \d+E\d+ when it gets interpreted as a float in scientific notation.<p>[0]<a href="https:&#x2F;&#x2F;www.brautaset.org&#x2F;posts&#x2F;yaml-exponent-problem.html" rel="nofollow">https:&#x2F;&#x2F;www.brautaset.org&#x2F;posts&#x2F;yaml-exponent-problem.html</a>
normie3000about 1 month ago
Google App Engine used to do this to environment variables defined in YAML. IIRC it would convert the string &quot;true&quot; to &quot;Yes&quot;, which was a fun surprise when deploying Java And NodeJS apps.
riffraffabout 1 month ago
Usual reminder that this is not a problem in YAML 1.2 released 15 years ago.<p>Sadly many libraries still don&#x27;t support it.
评论 #43671941 未加载
stephenrabout 1 month ago
It&#x27;s not a coincidence that YAML is a perfect acronym for &quot;yet another migraine looming&quot;.<p>I mean ok it is technically a coincidence but it definitely feels like the direct result of the &quot;what could possibly go wrong&quot; approach the spec writers apparently took
ghuntleyabout 1 month ago
See also <a href="https:&#x2F;&#x2F;noyaml.com" rel="nofollow">https:&#x2F;&#x2F;noyaml.com</a> (feel send in PRs with your gripes&#x2F;gotchas re: YAML)