February 2014

Gavin Pickin

Techie Gotcha - Debugging CFML Errors - Unhelpful Error Messages

CFML Language, CFML Server, Techie Gotchas

Debugging your code is one of the biggest parts of your job in my mind, and I believe that you can tell how good a developer is (up to a certain point), by how they debug their code. A lot of people seem to Ask Stack Overflow first, then ask their coworkers, read on google next, and then they try and figure it out themselves these days. Its funny, because, I think it should be the opposite order, you should work it out yourself, then read google, then ask a coworker, then ask for help at Stackoverflow… but I think I'm one of those who can debug pretty well, mainly because I've made LOADS of mistakes in my time.

Just recently, we had a pretty good bug pop up, and since I didn't find anything too helpful elsewhere, I decided I better blog it, for myself down the road, to share and to help those who do google because mindlessly asking on Stack Overflow.

A little background, this site is running on ColdFusion, we have a bare bone web directory, and most of our code is mapped into the app. I went to lunch, everything was working, I get back, and somehow, while I was at lunch, an error started happening, and none of the developers knew why. Its on our Dev server, so no biggie, so I sit take an take a look.

This is a legacy site, lots of old code, I do a lot of work with older code, we're dragging it into this century, but baby steps. So the code breaks with a CFAjaxProxy tag. Yes, I know, we could use jQuery, we do on our new stuff, but we haven't attacked that yet.

So the error code is

The specified CFC cms_files.CFCs.functions could not be found.


Message detail:

The path to the CFC must be specified as a full path, or as a relative path from the current template, without the use of mappings.


Reading this error message, first I think, thats odd, we definitely have been using mappings with this, for a long time, why in the world would mappings all of a sudden not work. 

Looking in the bug tracker, it looks like you could not use mappings before, and according to the bug, Full Paths would blow up too, but this is marked as fixed, and this is what I assume mappings now work, but that means the ERROR message is Incorrect.

So first thing I do is make sure all the mappings are still in place, and see if anyone "messed" with them. Nothing has changed, just as the developers said.

That error message just irks me… I smell something is not right.
So I put in the full path in, guess what? 


I was right, it has nothing to do with finding the CFC… I now think its the fact it can't find a VALID CFC. 

I reload our application, and sure enough, the CFC has an error in it. One of our developers had updated a function, but it wasn't correct, and because they didn't reload the Application, the other functions were working off our Application Singleton Version, and the CFAjaxProxy instantiates the CFC for each call... so they didn't see the error, they just got a vague and misleading error message about not being able to find the CFC.

So if you are getting this error, 

  1. Mappings do work
  2. It might be the fact the CFC is invalid, not necessarily due to not being found at that path

I checked this in Railo, and it identifies the error much better.

For a incorrect path to a CFC you get these results.

For a correct path to a CFC with an error, you get these results.

Railo tells you there is an error in the CFC, and even identifies where it is, so you can fix it. In this case, I was missing the word FUNCTION in my function definition. Error messages should be helpful, that is the reason they exist... they should be accurate, and helpful. In this case, Adobe ColdFusion failed at both of those points.

I have seen a few other error messages similar to this. 

One of the main ones is using cffile.
If there is an error renaming the file, and there is a problem with the path of the source file, usually a forward slash back slash issue when changing from Windows to Linux, it states the problem is with the DESTINATION file, although its actually the SOURCE file.

Before I go post a bug to fix an error message, which seems picky, but hey, its important I believe, I'm going to install CF10 and CF11 to see if these error messages have been fixed over time.

Otherwise, I will file bugs for them… so check back and see CFAjaxProxy and CFFile error messages in a future post.



Blog Search