TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

YAML: The Norway Problem (2022)

222 点作者 carlos-menezes大约 1 个月前

30 条评论

azernik大约 1 个月前
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.)
weinzierl大约 1 个月前
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 未加载
gnabgib大约 1 个月前
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 未加载
pkkm大约 1 个月前
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 未加载
anvandare大约 1 个月前
&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_quacko大约 1 个月前
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 未加载
alkonaut30 天前
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 未加载
ashishb大约 1 个月前
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 未加载
quechimba大约 1 个月前
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 未加载
umanwizard大约 1 个月前
“Be liberal in what you accept” rears its ugly head once more.
评论 #43669792 未加载
评论 #43673521 未加载
评论 #43670695 未加载
xelxebar大约 1 个月前
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 未加载
nnurmanov大约 1 个月前
Another solution is to change the country name:)
评论 #43670237 未加载
评论 #43670971 未加载
hgomersall大约 1 个月前
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 未加载
raffraffraff大约 1 个月前
Why not just use quotes all the time for strings?
评论 #43671450 未加载
评论 #43670571 未加载
评论 #43670537 未加载
firesteelrain大约 1 个月前
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 未加载
kazinator大约 1 个月前
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.
dissent大约 1 个月前
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 未加载
thund大约 1 个月前
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>
ajuc大约 1 个月前
YAML is just doing too much and trying to be too clever.
cirwin30 天前
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”?
thyrsus大约 1 个月前
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 未加载
TZubiri大约 1 个月前
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 未加载
endofreach30 天前
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 未加载
singpolyma3大约 1 个月前
Quote your strings
评论 #43669471 未加载
maelito大约 1 个月前
We should use very basic yaml parsers without these kind of functions.
praptak大约 1 个月前
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>
normie3000大约 1 个月前
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.
riffraff大约 1 个月前
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 未加载
stephenr大约 1 个月前
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
ghuntley大约 1 个月前
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)