Had I Known ...

Earlier today I was asked to take a look at a piece of code that was written a couple years ago to solve a very specific problem at a European branch of the day job. It was just a simple Python script that called a series of SQL queries to correct some information that was missed by a sync mechanism between three applications. There was no documentation for how the code was supposed to work, nor was there any specification document providing the gist of the tool. However, being the organization's predictable fool, I agreed to take a look in an effort to discover and fix the reported problem.

Some Python Code

When the .zip file came through I was quick to get started on the debug process. The problem was that, after running well for two years, the code would throw errors galore and quit. In with the source files were some log files, so I started with those and quickly found the cause of the problem. The next challenge would be to resolve the problem, which naturally involves looking at the source code. I fired up a text editor and started digging into the Python, but something seemed a little off with what I was looking at. The coding style and terse comment blocks looked incredibly familiar.

It was my code. The attribution block at the top of the page had been completely removed, and any reference to specific GitHub issues to explain why certain code blocks did what they did were scrubbed, but the code was most certainly from a project that I had written in 2015 to work as an "interim solution" to a problem here in Japan. Locally, the Python project was certainly a short-lived fix. However, it seems that someone shared it with the German team in 2016 to solve a similar problem they were having and this temporary solution became a permanent one.

Less than 20 minutes after receiving the code from my European colleagues, I fired off and email outlining the proper fix to their problem, which would make this malfunctioning code completely irrelevant1. Had I known this fix would have been shared outside of the country, I would have written the tool a little more intelligently. There would be better error checking and more links in the code pointing to the GitHub wiki page where the software was most certainly documented. Then again, had I known this fix would have been shared outside the country, I would have likely followed up with international teams to make sure they did not use the sync hack after a proper resolution to the problem was found.

This does make me wonder just how much of my code has been handed out to the various international teams without my knowledge2. A lot of it was designed for a very specific internal purpose, so I doubt much of it would work elsewhere without a bit of effort.

  1. The problem turned out to be the code was moved to a new server running an incompatible version of Python. I had written the code for Python 3, but the server Germany set up was running an older version.

  2. and my name. Why delete the name of the developer? Why remove GitHub issue numbers from comments? I have a feeling I know who did this, but it doesn't make the unnecessary editing of comments any more understandable.