Skip to content

TESTBOX-456: Simplify BoxLang CLI url scope guard to a param - #205

Merged
lmajano merged 1 commit into
developmentfrom
fix/testbox-url-scope-param
Aug 30, 2026
Merged

TESTBOX-456: Simplify BoxLang CLI url scope guard to a param#205
lmajano merged 1 commit into
developmentfrom
fix/testbox-url-scope-param

Conversation

@lmajano

@lmajano lmajano commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

Description

TESTBOX-456 — follow-up simplification to the url-scope-in-CLI-mode guard added in TESTBOX-454/TESTBOX-455 (#202/#203).

The existing guard in runRaw()/dryRun() (system/TestBox.cfc) is:

if ( !variables.IS_CLI || isDefined( "url" ) ) {
    if ( structKeyExists( url, "testBundles" ) ... ) { ... }
    ...
}

This works, but it's more machinery than the problem needs: two conditions to reason about, and the whole url.* block is conditionally skipped.

This PR replaces it with a single param name="url" default={}; at the top of each function, before the url.* checks:

param name="url" default={};
if ( structKeyExists( url, "testBundles" ) ... ) { ... }
...

param is a no-op wherever the scope already exists — every engine, every non-CLI request (url is always present in real HTTP requests) — and only actually defaults it in the one case that was ever broken: BoxLang CLI, where the scope isn't registered at all. This removes the branch entirely; the structKeyExists/isNull checks below now just run unconditionally against a struct that's guaranteed to exist.

Verification

Verified against real BoxLang v1.17.0+58, not just reasoned about:

  • Confirmed isDefined( "url" ) is false in genuine CLI mode (server.boxlang.cliMode == true), same as before.
  • Confirmed a bare param name="url" default={}; in that context resolves without throwing, and afterward url behaves as a normal empty struct (structKeyExists/key access work; no more scope-resolution KeyNotFoundException).
  • Confirmed the param effect does not leak across sibling methods on the same component instance (tested via a 2-method CFC probe) — hence why both runRaw() and dryRun() each need their own param line, not just one at construction time.
  • Ran TestBox.dryRun() and TestBox.runRaw() directly against real bundles (tests.specs.mockbox.MockBoxTest, tests.specs.mockbox.MockBoxSetRangeTest) in true CLI mode with the fix applied — both complete without error.

No new automated test was added: this path is specifically about server.boxlang.cliMode, which is only ever true under a genuine CLI invocation — not reproducible inside the existing spec-bundle test harness (which runs the same test suite across all engines, none of which set that flag). Verification was done by direct invocation against the real engine as described above.

Jira Issues

Bug Tracker: https://ortussolutions.atlassian.net/browse/TESTBOX-456

Type of change

  • Improvement

Checklist

  • My code follows the style guidelines of this project cfformat
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works (see Verification above for why - not reproducible in the cross-engine spec harness)
  • New and existing unit tests pass locally with my changes

Generated by Claude Code

Replace the two-condition if-guard (!IS_CLI || isDefined("url")) with
a plain `param name="url" default={};` at the top of runRaw()/dryRun().
param is a no-op wherever the scope already exists (every engine, every
non-CLI request) and only defaults it in the one case that was ever
broken - BoxLang CLI, where the scope isn't registered at all.

Verified against real BoxLang v1.17.0+58: dryRun()/runRaw() both
complete without throwing in CLI mode (isDefined('url') == false).
@lmajano
lmajano merged commit 16e7278 into development Aug 30, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants