joereger.com

something opinionated and awesome goes here


12
Month
6
Day
2005
Year
2
Hour
28
Minute
PM

Interesting (and crappy) Template Bug



Interesting template bug happening right now. For some reason the latest update has templates doubling themselves, meaning that sites are double-output. Odd as heck. I'm on it.

Update: Found the source of the duplication... one of the database migration/upgrade scripts which was run at the last build deployment. I haven't yet figured out the best solution. We have thousands of user-created templates and I'm trying to figure out how to work around the duplication issue. One way is to simply cut the second half of all templates off, by character count. I'd like a little more robustness/checking in the final version. Sorry for the bug. I'll get on it asap. However, don't expect anything before tomorrow afternoon... I need time to test something like this. Updates as I work on it.

Update: Oh, it's gonna be an open source http parsing sort of thing. My current thought is that I'll create a DOM out of the html and prune the second HTML node. This assumes, of course, that there is one and that all templates start with an HTML open tag (they should). I'll run tests locally to see whether this corrects things.

Update: Doh!
There are HTML documents for which NekoHTML cannot properly generate a well-formed XML document event stream. For example, documents with multiple tags are inherently ill-formed because XML documents may only have a single root element.

Back to the drawing board... or off to check out jTidy.

Update: Oh, the irony. The issue was caused by a piece of code that was launched to fix another bug. These bugs are like bunnies!

Update: First attempt to use jTidy to fix has failed... it noticed the copy of the html and removed the html tags, but it folded what was between them into the first template... which is worse off than where we are now. Onward.

Update: After a night's sleep the problem presented itself as rather trivial. All I have to do is look for the closing html tag and delete everything after it. Funny how a little sleep does that. I was looking at it from the wrong angle. Working up the code now.

Update: Code's done. Downloading production templates to test with.

Update: Tested with production code. My approach is forgiving for non-conforming templates. Doing a build test right now.

Udpate: Build deployed. User templates are fixed except for four of them that I'll address manually (I expected this based on the test and didn't want to write code for a case that a) won't happen again and b) is faster to manually handle).

Big problem with the main reger.com site, however. Not popping up. In doing the launch I also launched some new code dealing with port numbers... probably the culprit. Debugging right now.

Update: The site is actually up at http://www.reger.com/about/. It just can't be accessed at www.reger.com.

Update: Fixed the bug. Reger.com is working now. Fixed the four templates manually. All seems to be in order now.

Update: So, a little ahead of schedule on the fix(es). The template bug was the worst. What made it tough to fix was the fact that I had to write code to adjust user-created data. User-created data is inherently unpredictable. I have to make sure that my code doesn't obliterate the time that users have invested in their templates. Fear of doing so is what forced me to slow down, think through it, get a night of sleep and test everything before I launched it. I'm not claiming 100% effectiveness... I could have screwed up somebody's template... but I should be fairly close.

Sorry to all for the bug and the few minutes of downtime required to fix it.