TESTBOX-456: Simplify BoxLang CLI url scope guard to a param - #205
Merged
Conversation
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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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: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 theurl.*checks:paramis a no-op wherever the scope already exists — every engine, every non-CLI request (urlis 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; thestructKeyExists/isNullchecks 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:
isDefined( "url" )isfalsein genuine CLI mode (server.boxlang.cliMode == true), same as before.param name="url" default={};in that context resolves without throwing, and afterwardurlbehaves as a normal empty struct (structKeyExists/key access work; no more scope-resolutionKeyNotFoundException).parameffect does not leak across sibling methods on the same component instance (tested via a 2-method CFC probe) — hence why bothrunRaw()anddryRun()each need their ownparamline, not just one at construction time.TestBox.dryRun()andTestBox.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 evertrueunder 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
Type of change
Checklist
Generated by Claude Code