Reverse Mystery Bugs

For a change this is about software bugs, not insects. :-) Ever have a reverse mystery bug? This is not one that’s hard to find or understand, but one that’s brutally easy to understand and fix. The mystery is how the code ever worked in the first place. I had one of those this morning.

The AppleScript I use to manage the quotes of the day on Cafe con Leche stopped working mysteriously. Running the script with the result log open made the problem obvious: it couldn’t find the file index.html in my cafeconleche directory. Well, that’s an easy fix. The file isn’t named index.html and hasn’t been for many moons. It’s named index.phtml (because it uses PHP to include some files). I changed the name of the file the script was trying to open to index.phtml, and all was well.

But here’s what I don’t understand: why didn’t this break yesterday? and the day before that? and the day before that? It was working just fine until this morning. was there a symlink from the old index.html name, and if so why did it vanish? Was my script updated previously, and somehow got replaced by an older version? And if so, how and why?

Hmm, maybe Time Machine can help? Yes, it does look like the old version of the program did indeed open the correct file, index.phtml. Sometime since yesterday morning the file changed to try to open index.html instead, but why and how? AppleScript code is really a mix of text and binary, not plain text like source code should be. Even the source is saved in a compiled format and then decompiled when you edit it, so maybe the compiler mucked up somehow? But why would it change a constant string? I have no answers.

2 Responses to “Reverse Mystery Bugs”

  1. J Donald Says:

    By combining text and binary, AppleScript violates the law of Least Surprise. It’s got some cool ideas, but it’s as proprietary as VBScript for Applications. Not that we shouldn’t innovate and try new things, but personally, I prefer to use good old-fashioned, non-cutting-edge Perl. Works on Mac, works on Linux, works on Windows, works on Solaris, etc.

  2. Miles O'Brien Says:

    Here’s an article about using Ruby instead of Applescript.

Leave a Reply