Archives for: April 2009

ExpandPath() bug in ColdFusion 8

by dr-nick Email

I rarely seem to write about the day job in my blog, but I want to make sure that this gets recorded somewhere that google might find, so that it might save someone the 4½ hours it took me to resolve.

We've got a development environment based around virtual ColdFusion 8 development servers which run a codebase from across a couple of subversion working copies (WC). The webroot maps to one WC, there's a common folder (with common code/resources for several applications) which is aliased below the webroot in apache, and another WC for custom tags. When we commit working, tested code to trunk, post-commit hooks on the repos update the relevant working copies on the public web servers.

So, the problem yesterday was that code which worked fine on the test environment was failing on the live server. The code was using ExpandPath() to (try to) return the absolute filesystem path for a web-relative path supplied. It worked on the test server (let's say it returned /etc/webroot/ for /), but on the live site, it returned something like http://www.example.com/siteCheck/http:/www.example.com/ instead. Obviously this isn't a valid filesystem path >:XX

Googling pulled up a link to a page by Mark Drew which didn't reference my particular bug, but there was a comment by Mark Mandel which suggested that in the absence of a CF mapping for the webroot, it looks to the apache mappings (and possibly mod_rewrite rules) for its path resolution. As our live server sits behind a load balancer, this fits with the very broken ExpandPath() result we saw.

In the end, there's a very simple solution. Set a mapping in the CF Administrator for / to the actual filesystem path for the webroot. It shouldn't have any other side effects, but it completely fixes ExpandPath(). Methinks that CF8 is trying to be too clever...

Anyway, that's that for today. At some point I'll get back to normal service and post some cute photos of Jess.