The bug that keeps my blog humble

When your past self sets traps for you
Fund this Blog

A few years back, I wrote a blog post to give some writing tips. I have a habit of writing on an external distraction free editor then copy and paste it to my blog when ready. For this entry, there was a problem. Whenever I hit the "Publish" button, I got a 500 Internal Server Error. I didn't have the time to debug it, so I kept the entry as a text file until I could analyze my error logs.

When I got home, I connected to my server, and parsed through the error logs. To my surprise, there was no entry for the time and date. So I loaded my dashboard, ran a tail command to monitor the logs while I saved the entry.

It happened again. The website redirected to my error page, but no entries in the error logs. A long time ago, my website didn't support Unicode characters, but I knew that I had fixed that. I created a dummy post where I inserted a whole bunch of emojis, and unsurprisingly, it published just fine. So what was the problem?

I spun up a local copy of my website on my dev machine, I copied and pasted the same article I wanted to publish, but this time locally. The result? 500 Internal Server Error. It's been a while since I had such an annoying bug on the blog, I was both frustrated and excited to debug it.

I combed through the blog engine code. I explored the controller that saves and updates blog entries. To my surprise, nothing jumped out. It looked like ordinary PHP. But then again, it's PHP. Was it possible that something suddenly changed in PHP? In the past, I had upgraded PHP from PHP 5.4 to 5.5 only to have my blog collapse. All because "The software should be used for good, not evil". But not the case this time. PHP was not to blame.

I've exhausted all code debugging approaches that I could think of, so I turned to trial and error. I decided that maybe it was a weird character in the text that caused a problem. A secret combination of letters designed to take down my blog. It doesn't even make sense. But anyway, I did that. I split the post in two. I attempted to publish the second half, and it worked fine. So this was a viable path.

I deleted the content and inserted the first half. Boom! 500 Error. Now I took that half, and split it in half and published. The first half was successful. Second half failed, we are getting somewhere.

Copy, split, publish, and repeat. For the last paragraph, I split it in half, and both halves failed. So something I wrote in this paragraph was causing my blog engine to cough. I didn't understand why. There was nothing unusual in it. I ran it through a script to see the char code position, and it was all in the ASCII range. I read and reread the paragraph and it finally hit me. Or more like, it jotted my memory.

My favorite word in English is "Viviparous". I will probably never write a piece on this blog where it will be appropriate to use this word. But I find myself trying to sneak it into a blog post from time to time. It sounds fantastic in my head, it conveys the imagery of a vivacious being giving birth. And I would love to use it to describe a powerful idea coming to life. But when I read it out loud, I strike it off immediately. If I still find myself wanting to use the word, I go to the next step: Have the post read to me.

There were two words in the paragraph that were clearly highlighted and staring back at me. I remembered the night where I thought it would be fun to add a piece of code that will keep me humble. Whenever I start feeling too cocky when my blog goes viral, I need something to bring me back to earth. The problem was I made a mistake in the implementation so I never saw the error message I was supposed to see. And several years later, I had completely forgotten about it.

I looked through my blog engine and found the middleware that ran whenever I saved a blog post. Right there in the code were these lines.

function containsForbiddenWords($content, $forbiddenWords) {
    foreach ($forbiddenWords as $word) {
        if (stripos($content, $word) !== false) {
            return true;
        }
    }
    return false;
}

$FORBIDDEN_WORDS = [
    'viviparous',
    'vivacious',
    'delve',
    '...'
];

if (containsForbiddenWords($post_content, $FORBIDDEN_WORDS)) {
    // TODO: use blog engine Error class when available
    header("HTTP/1.1 500 Internal Server Error", true, 500);
    // error_log("Don't be too cocky now");
    exit;
}

Not only I never updated the code to use the proper error handling, I had also commented out the error log function. I remember this passage in Brave New World quite vividly:

"Human beings used to be ..." he hesitated; the blood rushed to his cheeks. "Well, they used to be viviparous."

I just love this word. I feel like wearing Guy Fawkes masks just reading it. But I also knew that there is never a good reason to use this word on my blog ever. There are several words in that list that automatically get flagged when I use them.

This time the verdict won't be vengeance, a vendetta. The forbidden words shall remain, continuing this vicious cycle. I've added a new flag on my blog to forgive blog posts that are "meta" (vivaciously included in the list).

Until we convene again in this veritable vortex of vocabulary, I remain your devoted servant in the cause of verity and virtue. May your voyages prove victorious, your ventures vivifying, and your very existence a vibrant victory against the vacuous and the vile.

Farewell, and remember... ideas are bulletproof, but verbose villains in velvet must eventually vacate!


Comments

There are no comments added yet.

Let's hear your thoughts

For my eyes only