Skip to content

fix(cli): server-required commands throw instead of silent-exit (#2229) - #2237

Merged
bpamiri merged 2 commits into
developfrom
claude/pedantic-mirzakhani-27b839
Apr 23, 2026
Merged

fix(cli): server-required commands throw instead of silent-exit (#2229)#2237
bpamiri merged 2 commits into
developfrom
claude/pedantic-mirzakhani-27b839

Conversation

@bpamiri

@bpamiri bpamiri commented Apr 23, 2026

Copy link
Copy Markdown
Collaborator

Summary

Closes #2229.

Changes

File Change
cli/lucli/Module.cfc Added $requireRunningServer() helper; converted 9 call sites
cli/lucli/tests/test-server-required-exit-codes.sh New shell regression test (7 commands)
CHANGELOG.md [Unreleased] › Fixed entry

Net -4 LOC across Module.cfc — guard collapses from ~5 lines per site to 1.

info() status probe at line 596 is intentionally left alone — it reports server status, doesn't require server.

Test plan

  • bash cli/lucli/tests/test-server-required-exit-codes.sh (requires no server on 8080/60000/3000/8500 — the test guards this)
  • Manual: stop server, run wheels routes — expect red diagnostic + exit 1
  • Manual: stop server, run wheels test — expect red diagnostic + two yellow hints + exit 1
  • Manual: with server running, wheels routes / wheels migrate info / wheels db status continue to succeed (happy-path unchanged)
  • CI: Lucee 7 + SQLite PR gate
  • CI: compat matrix

Notes

  • migrate() has try { runMigration } catch (MigrationError e)Wheels.ServerNotRunning is a different type, so it propagates cleanly. The typed exception is load-bearing; a catch (any) anywhere in the chain would silently revert the fix.
  • Live end-to-end verification requires reinstalling the module from source — the stale ~/.wheels/modules/wheels/Module.cfc will shadow worktree changes otherwise (exactly the case wheels doctor: detect stale ~/.wheels/modules/wheels/ install that shadows source checkout #2223's wheels doctor was shipped to catch).

…silent exit (#2229)

Nine LuCLI commands printed a red "No running Wheels server detected"
diagnostic then `return ""` — producing exit 0. MCP clients and shell
automation couldn't distinguish "succeeded with no output" from "server
down, nothing ran". The issue listed four (routes, reload, test, console);
the same-root-cause scan surfaced five more with an identical pattern
(migrate, seed, db status, db version, generate admin). All nine fixed
together — the issue checklist explicitly covers "any others surfaced
by audit".

Mirrors the #2211/#2214/#2215 pattern: keep the out() diagnostic, throw
a typed `Wheels.*` exception so LuCLI's Picocli ExecutionExceptionHandler
surfaces exit 1.

- New `$requireRunningServer(hints)` private helper consolidates the
  guard — returns the detected port on success, throws
  `Wheels.ServerNotRunning` on failure.
- Nine call sites converted: reload(), routes(), console(),
  generateAdmin, runMigration, runSeed, dbStatus, dbVersion, runTests.
- `info()` status probe at line 596 intentionally left alone — it
  reports server status, doesn't require server.

Net -4 LOC across Module.cfc despite adding the helper + docblock,
because the guard boilerplate collapses from ~5 lines per site to 1.

Regression test `test-server-required-exit-codes.sh` invokes each
command with no server and asserts exit != 0 plus the diagnostic.
Console is excluded from the live test (its success path reads stdin,
making headless exercise awkward); it's covered by type parity with the
other throws.
@github-actions github-actions Bot added the docs label Apr 23, 2026
@bpamiri
bpamiri merged commit b0e42f5 into develop Apr 23, 2026
4 checks passed
@bpamiri
bpamiri deleted the claude/pedantic-mirzakhani-27b839 branch April 23, 2026 01:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(cli): silent-exit when no server running — routes, reload, test, console

1 participant