Bit in the ass by a typo

One of my common typos bit me in the ass tonight.

As part of a fiendish plan to learn new technologies by actually building stuff with them instead of just reading about building stuff with them, I’d set myself the weekend goal of putting up an internet-facing Django application using lighthttpd and FastCGI instead of the usual (and recommended) Apache/mod_python combination. I’d tried out FastCGI once with Rails, and was using lighthttpd elsewhere to serve up static content, but had never used them together. (And to mix things up some more, SQLite3 instead of MySQL on the back end, but that’s not part of tonight’s problem.)

Two hours in, after an install hiccup and a few minor problems, “hello world” was working. A short time later, simple dynamic content (from a single table) was being served up. Except the Django admin interface didn’t quite look right. It wasn’t getting styled. Firebug confirmed that the HTML looked O.K., but firebug wasn’t seeing any CSS. Typing in the relative URL of the admin style sheet got me to the style sheet, so the path through FastCGI wasn’t the problem. But the page wasn’t getting styled. WTF!?! Clearing the browser cache didn’t help, nor did restarting firefox. Uh… Uh…

In the middle of asking for help on the #django IRC channel, I spotted the problem.

While fleshing out lighthttpd.conf, I’d speculatively added some missing mime types. If I’d been pair programming, my pair might have asked “are you sure you need to do that yet?” and I’d have had to agree ‘no’, and would now be writing about something else. Instead, with nobody there to stop me, I’d added

  ".js" => "application/x-javascript",
  ".css" => "test/css",

and the door down the rabbit hole was opened.

Do you see the problem? I didn’t, even after staring at it a half-dozen times, because I know what I’d meant to type. But what I’d actually typed was

  ".css" => "test/css",

which caused style sheets to be served up with an almost correct mime type. The sad thing is that I’ve made this typo before in similar contexts. It may be that too much testing has warped my muscle memory.

Comments are closed.