Repository navigation
docs(web/guides): correct environments guide load order, WHEELS_ENV detection, and env-switch docs - #3067
Conversation
…rder and env-switch behavior Audit-driven corrections for core-concepts/environments-and-configuration.mdx: - Fix config load order: app.cfm (pseudo-constructor, every request) -> environment.cfm -> framework defaults -> settings.cfm -> config/<env>/settings.cfm -> services.cfm -> routes.cfm - app.cfm executes on every request, not once per app start - Scaffold hard-codes set(environment="development"); WHEELS_ENV is not read by environment.cfm or the wheels CLI; document the two edits (env() read + remove scaffold .env line) required to drive it - Remove set(environment=...) from the settings.cfm example and warn about the half-switched-app failure mode - Replace fictional testing/production "typical settings" rows with the real framework defaults; move log rotation / HTTPS to web server / SecurityHeaders middleware - Add runtime environment switching section: ?reload=<env>&password=..., allowEnvironmentSwitchViaUrl gate semantics (#3036/#3038/#3058) - Cite open issues #3059, #3060, #3062 for current caveats Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Signed-off-by: Peter Amiri <peter@alurium.com>
There was a problem hiding this comment.
Wheels Bot — Reviewer
TL;DR: This PR corrects the environments-and-configuration guide to match audited framework behavior — config load order, config/app.cfm per-request execution, WHEELS_ENV non-detection on stock apps, the set(environment=...) half-switch trap, real per-environment framework defaults, and a new runtime env-switch section documenting the allowEnvironmentSwitchViaUrl gate. I independently re-verified every factual claim against framework source at this head SHA and found no discrepancies. Verdict: approve.
Verification (claim-by-claim, against 73393c8c7)
- Load order —
config/environment.cfmincluded atvendor/wheels/events/onapplicationstart.cfc:204; environment-derived defaults (enablePublicComponent,allowMigrationDown, caching/debugging includes) computed at:245-313;config/settings.cfm+ per-env settings at:325-328;services.cfmandroutes.cfmafter that. The guide's reordered bullet list (environment.cfm before settings.cfm) is correct; the old order was wrong. config/app.cfmper-request —include "../config/app.cfm";sits in thepublic/Application.cfcpseudo-constructor (line 105, outside any function), so it executes on every request. The old "runs once per app start" claim was wrong; the replacement text is accurate.WHEELS_ENV—config/environment.cfm:9(and thecli/lucli/templates/app/config/environment.cfmscaffold) hard-codeset(environment = "development").grep -rn WHEELS_ENV cli/luclihits only generated-app templates, confirming the CLI ignores it. In the templatepublic/Application.cfc:57-81, the variable's only effect is selecting the.env.<name>overlay — exactly as the guide now says..envshadowing —env()atvendor/wheels/Global.cfc:597-607checksapplication.env(populated from.env) beforeserver.system.environment, so the scaffold'sWHEELS_ENV=developmentline (cli/lucli/templates/app/_env:4) does shadow OS exports. The two-edit instruction is correct and necessary.set(environment=...)in settings.cfm warning — defaults likeallowMigrationDown(onapplicationstart.cfc:300-304),enablePublicComponent(:274-279),showErrorInformation/showDebugInformation(vendor/wheels/events/init/debugging.cfm:22-28), and the caching flags (vendor/wheels/events/init/caching.cfm:15-21) are all derived beforesettings.cfmloads at:325, so the half-switched-app description is accurate.- Environments table — testing/production rows now match real code: debug UI off outside development (
debugging.cfm:26-28), errors hidden only in production (debugging.cfm:22-25),/wheels/*public component development-only (onapplicationstart.cfc:276-279), caching on outside development (caching.cfm:15-21). The removed "clean DB reset / deterministic time / caches warmed / log rotation / HTTPS" claims have no corresponding code paths — good removals. - Runtime switch section —
$resolveAllowEnvironmentSwitchViaUrl(onapplicationstart.cfc:516-524) returns any explicit boolean as-is and otherwise!ListFindNoCase("production,testing,maintenance", environment), matching the documented defaults exactly. The same-environment no-op is enforced by theenvironmentSwitchAlreadyAppliedshort-circuit inpublic/Application.cfc. - #3062 caveat — confirmed: the reload condition in
public/Application.cfc(~:268-277) passes when!Len(application.wheels.reloadPassword), so a blank password does permit anonymous restarts. Citing the open issue rather than papering over it is the right call.
Docs
All four code blocks on the page carry title="illustrative — ..." and none are {test:*}-tagged, consistent with the page's pre-existing pattern, so the pnpm verify:docs exit-0 claim is consistent. No v4-0-0-snapshot docs tree exists at this head, so no parallel page needs updating. No changelog fragment is required for a docs-type change per CLAUDE.md.
Commits
Single commit docs(web/guides): correct environments guide to audited config load order and env-switch behavior — valid type, 97-char header, subject describes the why. Conforms to commitlint.config.js.
No correctness, convention, cross-engine, test, or security findings. This is what a docs-audit PR should look like: every assertion carries a source citation, and the citations check out.
Audit-driven corrections to
web/sites/guides/src/content/docs/v4-0-0/core-concepts/environments-and-configuration.mdx. Each change is cite-checked against framework source (and live audit probes on lucee7/adobe2023); no editorial rewrites beyond the established findings.Corrections
Config load order reordered — the guide listed
settings.cfmbeforeenvironment.cfm. Actual order:config/app.cfm(Application.cfc pseudo-constructor) →config/environment.cfm→ framework defaults →config/settings.cfm→config/<env>/settings.cfm→services.cfm→routes.cfm.Evidence:
vendor/wheels/events/onapplicationstart.cfc:204(environment.cfm),:245-313(framework defaults),:325-328(settings.cfm + per-env settings),:380-386(services),:429(routes);public/Application.cfc:105(app.cfm include).config/app.cfm"runs once per app start" removed — it is included from theApplication.cfcpseudo-constructor and executes on every request; only itsthis-scope effects apply at app start. Evidence:public/Application.cfc:105; live probe showed 2 executions per plain GET on adobe2023 with zero reloads.WHEELS_ENVdetection claim fixed — the scaffold hard-codesset(environment = "development")and neitherenvironment.cfmnor thewheelsCLI readsWHEELS_ENV. Documented the two required edits: read it viaenv("WHEELS_ENV", "development")inenvironment.cfmAND remove the scaffold.env'sWHEELS_ENV=developmentline (env()checks.envbefore OS env, so it shadows exports). Evidence:config/environment.cfm:9,cli/lucli/templates/app/config/environment.cfm:9,cli/lucli/templates/app/_env:4;grep -rn WHEELS_ENV cli/luclihits only generated-app templates; liveWHEELS_ENV=production wheels infooutput byte-identical to plainwheels info.Removed
set(environment = ...)from the illustrativesettings.cfmblock and added a warning — setting the environment there yields a half-switched app (environment reportsproductionwhile verbose errors, dev caching flags, andallowMigrationDownpersist, since boot-derived flags are computed atonapplicationstart.cfc:245-313, beforesettings.cfmat:325). Live probe confirmed verbose error leakage (boom-markervisible at HTTP 500 while environment=production).Environments table rows replaced with real framework defaults — testing row claimed "Clean DB reset per spec, shorter timeouts, deterministic time" (no such code paths exist); production row claimed "caches warmed, log rotation, HTTPS enforced" (caching is merely enabled outside development,
vendor/wheels/events/init/caching.cfm:15-21; log rotation/HTTPS are not framework settings anywhere invendor/wheels). Now lists: debug UI off,/wheels/*public component disabled, caching on, URL env-switch blocked by default — with a note pointing log rotation/HTTPS to the web server /SecurityHeadersmiddleware.New "Switching environments at runtime" section (previous docs gap) — documents
?reload=<environment>&password=<reloadPassword>(params preserved through the restart redirect, fix: make URL environment switching work through the app reload restart redirect #3036),?reload=<current-env>as a no-op vs?reload=truefor a plain restart, switches intoproduction/maintenancesticking with params stripped afterward (fix(events): defer redirect-after-reload past onApplicationStart so URL env switches persist #3058), and theallowEnvironmentSwitchViaUrlgate: explicit boolean honored in every environment; unset defaults tofalsein production/testing/maintenance andtrueelsewhere (fix(events): honor explicit set(allowEnvironmentSwitchViaUrl=true) in production-like envs #3038,vendor/wheels/events/onapplicationstart.cfc:501-509+$resolveAllowEnvironmentSwitchViaUrl).Open-issue caveats cited instead of papered over:
reloadPasswordcurrently permits anonymous?reload=truerestarts (public/Application.cfc:272-277) — Reload-password contract drift: empty password leaves?reload=trueopen to anonymous restarts, warm-app wrong-password attempts are never logged or rate-limited, and the boot warning misstates behavior #3062.wheels reloadCLI can report false success —wheels reloadreports "Application reloaded successfully." when the HTTP reload request fails (4xx/5xx) #3059.Verification
pnpm verify:docs src/content/docs/v4-0-0/core-concepts/environments-and-configuration.mdx→ exit 0 (all code blocks on this page aretitle="illustrative — ..."config fragments per the writing-docs tagging policy; none are tagged{test:*}).Refs #3036, #3038, #3058, #3059, #3060, #3062
🤖 Generated with Claude Code