Misleading "client scope is not enabled" when a local var client = ... is used as a component handle
Summary
In a CFWheels app running on Lucee 7, declaring a local variable named client and then calling a method on it produces a confusing runtime error that implicates application configuration rather than the variable name:
function index() {
var client = paiApiClient(); // a component instance
var result = client.partInquiry(params.partNumber); // <-- 500s here
}
lucee.runtime.exp.ExpressionException: client scope is not enabled
The app never touches the client scope — clientManagement is intentionally off. The identifier client in client.partInquiry(...) resolves to the built-in client scope (which precedence-wins over the local var), and with client management disabled, reading it throws. The error message points at app config, so the actual cause (a poorly-chosen local variable name) is very hard to spot.
Why this is worth a CFWheels note
The root cause is Lucee/CFML scope-precedence (so the engine behavior itself isn't CFWheels' to change), but CFWheels developers hit this constantly because:
- Controllers and models are the natural place to grab a service/component into a local handle, and
client, request, form, etc. are tempting names.
- CFWheels already documents
url / form / session / cgi / request / application / cookie as unsafe local-variable identifiers in several places — but client is missing from that list, even though it's the same trap and arguably more confusing (the error names the scope, not the variable).
Requests (any one would help)
- Docs: add
client to the documented list of reserved scope identifiers that must not be used as local/var names (alongside url/form/session/cgi/request/application/cookie).
- Optional dev-mode diagnostic: when a
client-scope error fires while clientManagement is disabled, surface a hint like "identifier 'client' refers to the (disabled) client scope; did you mean a local variable?"
Environment
- CFWheels 4.0 (LuCLI), Lucee 7.0.0.395
- Discovered building a DataPAI feature in the Titan app; workaround was simply renaming the local to
apiClient.
Reported from a real migration; happy to provide a minimal repro if useful.
Misleading "client scope is not enabled" when a local
var client = ...is used as a component handleSummary
In a CFWheels app running on Lucee 7, declaring a local variable named
clientand then calling a method on it produces a confusing runtime error that implicates application configuration rather than the variable name:function index() { var client = paiApiClient(); // a component instance var result = client.partInquiry(params.partNumber); // <-- 500s here }The app never touches the client scope —
clientManagementis intentionally off. The identifierclientinclient.partInquiry(...)resolves to the built-in client scope (which precedence-wins over the localvar), and with client management disabled, reading it throws. The error message points at app config, so the actual cause (a poorly-chosen local variable name) is very hard to spot.Why this is worth a CFWheels note
The root cause is Lucee/CFML scope-precedence (so the engine behavior itself isn't CFWheels' to change), but CFWheels developers hit this constantly because:
client,request,form, etc. are tempting names.url/form/session/cgi/request/application/cookieas unsafe local-variable identifiers in several places — butclientis missing from that list, even though it's the same trap and arguably more confusing (the error names the scope, not the variable).Requests (any one would help)
clientto the documented list of reserved scope identifiers that must not be used as local/varnames (alongsideurl/form/session/cgi/request/application/cookie).client-scope error fires whileclientManagementis disabled, surface a hint like "identifier 'client' refers to the (disabled) client scope; did you mean a local variable?"Environment
apiClient.Reported from a real migration; happy to provide a minimal repro if useful.