Skip to content

fix(config): coerce .env values to numbers only when they are plain integers - #4606

Merged
bpamiri merged 1 commit into
developfrom
peter/env-integer-only-coercion
Oct 15, 2026
Merged

bpamiri merged 1 commit into
developfrom
peter/env-integer-only-coercion

Conversation

@bpamiri

@bpamiri bpamiri commented Oct 15, 2026

Copy link
Copy Markdown
Collaborator

Summary

loadEnvFile() turned every isNumeric() value without a . into a number with val(). That gave wrong values:

  • 1e3 became 1, because val() reads only the leading digits;
  • 007 became 7.

A value that was a single quote character also reached mid(value, 2, -1).

Now:

  • Values convert to numbers only when they match ^-?(0|[1-9][0-9]*)$. 007, 1e3 and +5 stay strings; 0, 42 and -5 still become numbers.
  • Quotes are stripped only when the value has at least two characters, so a lone ' or " survives as itself and parsing continues on the next line.

The same change is in all four copies of the parser:

  • this repo's public/Application.cfc;
  • the wheels new template;
  • examples/starter-app;
  • examples/tweet.

Existing apps keep the old parser in their own public/Application.cfc until they copy the change; the changelog fragment says so.

Not changed: the three legacy cli/src/commands/wheels/* settings parsers. They parse settings.cfm set() calls, not .env lines, and don't have the lone-quote crash. They do over-convert numbers, including decimals; that's a separate follow-up.

Testing

  • New:
    • an edge-values.env fixture with a spec block for 007, 1e3, +5, -5, a lone single quote and a lone double quote, plus a key after them to prove parsing continues;
    • a guard spec that every Application.cfc copy carries the integer-only check and no longer the old one.
  • Existing .env specs: unchanged, and passing.

directory=wheels.tests.specs.global on SQLite (45 bundles each; EnvFileParsingSpec all passing):

Engine Pass / fail / error Skipped
Lucee 7 355/0/0 0
BoxLang 355/0/0 0
Adobe 2023 354/0/0 1
RustCFML 354/0/0 1

The demo app boots, and / returns 200 on Lucee 7. Adobe 2025 couldn't start locally (a corrupted cached engine download). It's being covered by a compat-matrix dispatch on this branch.

🤖 Generated with Claude Code

…ntegers

loadEnvFile() converted any isNumeric() value without a "." through val(),
so 1e3 became 1 and 007 became 7. It now converts only values matching
^-?(0|[1-9][0-9]*)$; 007, 1e3 and +5 stay strings, while 0, 42 and -5
still become numbers. A value that is a single quote character no longer
reaches mid() with a negative length: quotes are stripped only when the
value has at least two characters.

The same change is applied to all four copies of the parser (this repo's
public/Application.cfc, the wheels new template, and the two examples).
Specs pin the edge values and guard that every copy carries the new check.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Peter Amiri <peter@alurium.com>
@github-actions

Copy link
Copy Markdown
Contributor

Wheels Test Results

7 469 tests   7 320 ✅  2m 27s ⏱️
  600 suites    149 💤
    1 files        0 ❌

Results for commit 7c4f47c.

@bpamiri
bpamiri merged commit fa9570e into develop Oct 15, 2026
34 checks passed
@bpamiri
bpamiri deleted the peter/env-integer-only-coercion branch October 15, 2026 19:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant