2021-10-16 The funniest bug I've seen in a pretty long time

I might be in the minority, but I actually do like debugging. It’s often like that sort of puzzle game (or an escape room;-)) where you need to find some hidden clues. And often at first you know nothing or very little, but then you gradually pinpoint the problem and finally find it.

And sometimes I am really amazed at what craziness lies hidden in the code. Today, I want to share a recent story which I find almost unbelievably hilarious.

So, we had a script which (among a few other things) copied a (tarred and bzipped) package to the server (as part of a deployment process). Since we needed to be able to access various versions of that package, we made the (shortened) Git commit hash part of its name. The process went smoothly for several months and then suddenly broke. After a short investigation it turned out that it tried to copy a non-existent file, called <package-name>-Infinity.tar.bz2 to the server.

Well, this being Node.js, I would expect undefined, null or my favorite [object Object] in the case of some bug, but Infinity??? Seriously, JavaScript?

Well, here is what happened: the commit hash was one of the command-line parameters, and the package we used to parse CLI arguments (it was an old version of yargs – it appears that the problem is fixed in one of the newer versions) was overzealous and tried to parse things that looked like a number as a number (which I think is a very bad idea – software trying to be clever is usually an accident waiting to happen!).

So, if a commit hash started with a letter, everything was ok. If a commit hash contained only digits (and didn’t start with a zero!), everything was ok. (If it only contained digits and did start with a zero, we would most probably also have a similar problem, though without the funniest „Infinity” part.)

Our commit hash, however, was two digits, then the letter e, and then further 4 digits.

When I understood what happened, I burst with laughter.

For some people, this will be yet another proof that JavaScript or Node.js is shitty technology. I beg to differ; this could happen with virtually any language, and in fact it seems to do more with the JS culture (which is probably not the best one in existence, I have to admit) than the technology itself. (Not that I care a lot about people’s opinions on technology I use – I’ve been using Emacs for about two decades now, I stopped caring a long time ago;-)!) Anyway, I wanted to share this little adventure in the hope of making you smile a bit:-).

CategoryEnglish, CategoryBlog, CategoryJavaScript