fix(cli): return error instead of panicking on invalid move-node/join-window direction - #443
fix(cli): return error instead of panicking on invalid move-node/join-window direction#443YuriNachos wants to merge 1 commit into
Conversation
…-window direction
|
Force-pushed to add regression coverage: the first push only tested |
5d5a7d3 to
854ba83
Compare
|
The red This PR touches exactly one file, Nothing in the CLI binary is reachable from that test. And the same So the breakage landed on |
|
The failing test |
|
Leaving a quiet note here since this PR hasn't had any eyes yet: it turns the CLI panic on an invalid direction argument into a proper error, with non-panic regression tests for move-node, join-window and consume-or-expel-window. The red |
Problem
A typo in the direction argument of
rift-cli execute layout move-node|join-window|consume-or-expel-window(e.g.move-node rignt)panicked with exit code 101 instead of returning a clean error:
The three commands fed the raw clap
direction: Stringstraight intoFrom<String> for Direction, whichpanic!s on any token outsideleft/right/up/down. The siblingfocuscommands already validatethis input through
parse_focus_directionand printError: Invalid focus direction '…'with exit 1.Changes
MoveNode,JoinWindow, andConsumeOrExpelWindowthroughparse_focus_direction(&direction)?inmap_layout_command(
src/bin/rift-cli.rs), matching the existingfocus/switchpath andthe neighbouring
SetLayoutarm. Invalid directions now yieldError: Invalid focus direction 'foo'; must be left, right, up, or downwith exit 1; valid directions are unchanged.
invalid_move_node_direction_returns_error_not_panicasserting the invalid path is an
Errcontaining"Invalid focus direction"(pre-fix this panicked).The
From<String> for Directionimpl incrates/rift-protocol/src/layout.rsis intentionally left untouched; it is simply no longer reached from CLI
input.
How I tested this
cargo nextest run -E 'test(invalid_move_node_direction_returns_error_not_panic)'→ PASS (was a panic before the fix).
rift-cli execute layout move-node|join-window|consume-or-expel-window <bad>→ exit 1 with the one-line
Invalid focus directionerror (previouslyexit 101 panic).
rift-cli execute layout move-node leftstill parses correctly andreaches the IPC layer (no false rejection of valid directions).
cargo +nightly fmt --all --check --verbose✅,cargo check --locked✅,cargo nextest run -E 'not test(/actor::reactor::tests/)'→ 384 passed.Full
cargo nextest run --no-fail-fast: the only failures are the 12pre-existing
actor::reactor::testshost-env baseline (multi-displaytopology), unrelated to this change.
Scope: CLI-input validation only — no changes to the layout engine, IPC,
config, or
Directionsemantics for valid values.