DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

James Moberg
James Moberg

Posted on

Misleading ColdFusion QueryAddColumn Error Message

While generating a ColdFusion query using QueryNew, I added a new column using QueryAddColumn and encountered a misleading error message.

The value of parameter 3, which is currently varchar, must be a interface java.util.List value.

Alt Text

The last time I checked, varchar was considered a valid "java.util.list value"... so what's the problem? In Adobe ColdFusion 8 or 9, I believe that the array parameter was optional. (I could be wrong.) If you omit the 4th parameter, the error message indicates that there's a problem with parameter 3 instead of the missing 4th parameter. I tested the same code using Lucee 4.5/5 and the new column is added without any error. (I also tested Railo 4 & the error returned was "Can't cast String [varchar] to a value of type [Array]".)

While a wrong error message is not a show-stopping bug, it doesn't provide any helpful assistance to determine what the actual problem is. Thankfully the online documentation (https://cfdocs.org/queryaddcolumn) highlights the array parameter as "required" (even though it wasn't for Lucee.)

Test it here

https://www.trycf.com/gist/bc948b141eea337a1927a311e6b500e9

Source Code

Follow-up

20190103: I've reported it to Adobe. It's bug #CF-4206471

Top comments (0)

Timeless DEV post...

How to write a kickass README

Arguably the single most important piece of documentation for any open source project is the README. A good README not only informs people what the project does and who it is for but also how they use and contribute to it.

If you write a README without sufficient explanation of what your project does or how people can use it then it pretty much defeats the purpose of being open source as other developers are less likely to engage with or contribute towards it.