ColdFusion · Exception

UndefinedVariableException: Variable [name] is undefined

What does UndefinedVariableException: Variable [name] is undefined mean in ColdFusion?

A variable was referenced that has not been assigned a value in the scope it was looked up in. This is distinct from an undefined array or struct element: this fires for a plain variable name, most often from a typo, a missing scope prefix (writing myVar instead of application.myVar), or a scope like SESSION that is not available at that point in the request lifecycle.

UndefinedVariableException: Variable [name] is undefinedAdobe ColdFusion · Lucee

Condition

A variable was referenced that has not been assigned a value in the scope it was looked up in. This is distinct from an undefined array or struct element: this fires for a plain variable name, most often from a typo, a missing scope prefix (writing myVar instead of application.myVar), or a scope like SESSION that is not available at that point in the request lifecycle.

Fix

Check the exact variable name and scope prefix for a typo first, since that is the most common cause. Guard genuinely optional variables with isDefined() or structKeyExists(), or set a default with cfparam rather than assuming the variable will always exist.

Pending source verification. Not yet checked against official documentation.

Related exception