Today I found myself chasing my tail for a bit. This function threw an exception at runtime, which indicates that the argument passed in does not match the designated cfargument type. I spent a half hour finding different ways to verify that both inputs, Group_ID and Max_Allowed, were indeed of type Numeric.
<cfargument name="Group_ID" required="yes" type="Numeric" />
<cfargument name="Max_Allowed" required="yes" type="Numeric "/>
<!--- If there are too many users, get rid of some --->
<cfif countActiveUsers(ARGUMENTS.Group_ID) gt ARGUMENTS.Max_Allowed>
<!--- Get the top users. In practice, this is sorted on some criteria. --->
<cfquery datasource="#Application.Datasource#" name="topUsers" maxrows="#Max(ARGUMENTS.Max_Allowed, 1)#">
FROM tbl_Users u
WHERE u.Group_ID = <cfqueryparam cfsqltype="cf_sql_numeric" value="#ARGUMENTS.Group_ID#">
<!--- Delete records for users not in the top set --->
<cfquery datasource="#Application.dsname#" name="deleteBottomUsers">
WHERE Group_ID = <cfqueryparam cfsqltype="cf_sql_numeric" value="#ARGUMENTS.Group_ID#">
User_ID NOT IN (<cfqueryparam cfsqltype="cf_sql_numeric" value="#ValueList(topUsers.User_ID)#" list="yes">)
<!--- Records deleted, return true --->
<!--- Do nothing, return false --->
The exception (edited for readability, relevance, and to protect the innocent):
CFCATCH.Message: The argument MAX_ALLOWED passed to function restrictActiveUsers() is not of type Numeric .
CFCATCH.Detail: If the component name is specified as a type of this argument, the reason for this error might be that a definition file for such component cannot be found or is not accessible.
So something strange is afoot. Upon further review, I realized that the cfargument for Max_Allowed shows type="Numeric ". Notice the extra space, which means ColdFusion is faihfully validating the type as Numeric-SPACE. This is an invalid data type, hence the exception.
Just goes to show how a fat-finger can throw you for a loop.