fix: reject incomplete CLI flags and empty JSON inputs - #9
Merged
Conversation
Missing --fault/--out/--port values and flag-shaped values now fail closed as USAGE_INVALID instead of silently defaulting or starting the sidecar. Help text lists valid faults and assurance modes, and unreadable JSON files no longer surface as INTERNAL_ERROR.
Comment on lines
+208
to
+209
| if (args.length === 0 || args.includes("--help") || args.includes("-h")) { | ||
| printHelp(); |
There was a problem hiding this comment.
🟡 Help masks malformed invocations
When --help appears anywhere, malformed commands and missing values exit successfully instead of returning a usage error. Both CLIs bypass all validation.
Prompt for agents
Validate invocations before treating help as successful in both cmd/crctl.js main and cmd/rail.js parseArgs. Define help only for an otherwise valid help invocation, so mixed inputs such as `explode --help`, `--fault --help`, and `--bogus --help` retain USAGE_INVALID behavior. Add deterministic tests for malformed inputs containing each help spelling.
Was this helpful? React with 👍 or 👎 to provide feedback.
Comment on lines
+56
to
+58
| const value = args[index + 1]; | ||
| if (value === undefined || value.startsWith("-")) { | ||
| throw usage(`${arg} requires a value.`); |
There was a problem hiding this comment.
🟡 Empty flag values bypass validation
An empty --out value runs the full demo without writing the requested file. An empty --port value starts a server on an ephemeral port.
Prompt for agents
Reject empty value strings in both cmd/crctl.js parseCliArgs and cmd/rail.js parseArgs before command execution or numeric conversion. Cover at least `--out ""` and `--port ""` with subprocess tests that require USAGE_INVALID and no demo/server execution.
Was this helpful? React with 👍 or 👎 to provide feedback.
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.
What
CLI usage now fail-closes on incomplete or unknown inputs instead of silently continuing.
crctlrejects missing flag values (--fault,--assurance,--out), flag-shaped values (--fault --json), unknown flags, incomplete commands, and extra positionals.--helplists refund faults, recovery-preflight faults, and assurance modes.USAGE_INVALIDinstead ofINTERNAL_ERROR.rail --helpprints usage and exits; it no longer starts the sidecar.--portwithout a value is rejected.Why
--faultwith no value previously ran the defaultnonescenario,--fault --jsontreated--jsonas a fault name, empty bundle files surfaced asINTERNAL_ERROR, andnode ./cmd/rail.js --helpbound a loopback port.How tested
node --testnode ./scripts/check.js