TESTBOX-454: Fix KeyNotFoundException [url] crashing every CLI run - #202
Merged
Conversation
Reported by the maintainer running ./testbox/run --stream --verbose against BoxLang v1.17.0+58: every CLI run crashed immediately after the recent CLI-runner fix (#201) cleared the way to reach this code, with: KeyNotFoundException: The requested key [url] was not located in any scope or it's undefined at ...ScriptingRequestBoxContext.scopeFind at ...Testbox$cfc.invokeFunction_runRaw(TestBox.cfc:408) Root cause: runRaw() and dryRun() unconditionally reference the `url` scope to support web-request query-string test filters (?testBundles=, ?testSuites=, etc.). The `url` scope only exists in a real HTTP request context - it is never registered at all when TestBox runs via the BoxLang CLI. #200 ("support full null runtimes") added a `structKeyExists( url, "testBundles" )` guard, but that doesn't help here: resolving the bare `url` identifier itself is what throws - structKeyExists() never gets a chance to run, since BoxLang has to look up `url` as a scope before it can pass it as an argument. Fix: skip these URL-based filter blocks entirely when variables.IS_CLI is true (already computed at class init). CLI users already have --filter-bundles/--filter-suites/--filter-specs for the same purpose via BoxLangRunner.bx, so nothing is lost. Verified locally against BoxLang v1.17.0+58: reproduced the exact reported crash against the real merged development branch first (structKeyExists guard included), then confirmed the fix with the maintainer's exact command (./testbox/run --streamingj --verbose, 4/4 clean runs), plus --dry-run and --stream, which exercise both patched call sites (runRaw() and dryRun()).
6 tasks
lmajano
added a commit
that referenced
this pull request
Aug 29, 2026
) #202 guarded the URL-based test filter blocks in runRaw()/dryRun() with plain `!variables.IS_CLI`, which assumes the url scope is never present in CLI mode. That's true today, but the guard shouldn't bake in that assumption - it should check reality instead of the engine mode. If a CLI context is ever running with a url scope registered (a future BoxLang change, an embedding runner, etc.), skipping unconditionally on IS_CLI would silently drop those overrides for no reason. Confirmed isDefined( "url" ) is the safe way to probe for this: unlike referencing the bare `url` identifier (which throws when the scope isn't registered), isDefined() on a scope name returns false without error. New guard: `!variables.IS_CLI || isDefined( "url" )` - run the block whenever we're not in CLI mode (unchanged, existing behavior) OR the url scope actually exists (covers any CLI context where it does). Only skip when neither holds, i.e. CLI with no url scope - which is where the original #202 crash happened. Verified locally against BoxLang v1.17.0+58: confirmed isDefined("url") returns false without throwing where a bare `url` reference does throw, then re-ran the full local repro (./testbox/run --streamingj --verbose, --stream, --dry-run) with the expanded guard - all clean, same as after #202. Co-authored-by: Claude <noreply@anthropic.com>
6 tasks
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
Every
./testbox/runCLI invocation (e.g../testbox/run --stream --verbose) crashes on BoxLang v1.17.0+58 with:Discovered right after TESTBOX-453/#201 shipped: that fix cleared an earlier crash that always happened before execution reached this code, masking this one. Now that runs get further, this is hit on every single CLI invocation, deterministically.
Root cause:
TestBox.cfc'srunRaw()(~line 408) anddryRun()(~line 527) unconditionally reference theurlscope, to support web-request query-string test filters (?testBundles=,?testSuites=, etc.):The
urlscope only exists in a real HTTP request context — it is never registered at all when TestBox runs via the BoxLang CLI. A prior fix (#200, "support full null runtimes") added thestructKeyExists( url, "testBundles" )guard, but that doesn't actually help: resolving the bareurlidentifier itself is what throws (BoxLang has to look the scope up before it can even pass it as an argument tostructKeyExists()) — the key-existence check never gets a chance to run.Fix: skip these URL-based filter blocks entirely when
variables.IS_CLIis true (already computed at class init). CLI users already have--filter-bundles/--filter-suites/--filter-specsviaBoxLangRunner.bxfor the same purpose, so nothing is lost.I installed BoxLang v1.17.0+58 locally, reproduced the exact crash against the real merged
developmentbranch (structKeyExists guard included) using the maintainer's exact command, then confirmed 4/4 clean runs with the same command after the fix, plus--dry-runand--stream(which exercise both patched call sites).Jira Issues
https://ortussolutions.atlassian.net/browse/TESTBOX-454 (related: TESTBOX-453 / #201)
Type of change
Checklist
Note: same as #201, this fix touches the CLI runner path, which isn't exercised by TestBox's existing test suite (that runs against CFML engine web servers, not the BoxLang CLI entry point) — verification here was a manual local repro against the actual BoxLang engine build, described above and in the linked Jira issue.
Generated by Claude Code