You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit a22bdfe
Browse filesBrowse the repository at this point in the historyBrowse files
fix(cli): reject invalid/unknown-flag positionals in hand-rolled arg parsers (#222)
The CLI now rejects a mistyped/unknown flag instead of silently turning it into a project name, hostname, or scaffolded filename.
## The bug
Three hand-rolled arg parsers captured an invalid leading-dash token as a positional instead of erroring — unlike every `parseArgs({strict})` parser and the sibling branches that already guard:
- `parseProjectArgs` (`status`/`link`/`rollback`/`cancel`): `void project status --foo` returned `name: '--foo'`, a bogus slug then sent to the platform — even though the sibling `delete` branch already rejects unknown flags.
- `parseDomainArgs`: an unknown flag was captured as the hostname (or silently dropped).
- `parseMiddlewareArgs` (`void gen`): any name was accepted, so `void gen middleware --foo` scaffolded a file literally named `001.--foo.ts` — while the sibling gen parsers (model/migration/cron/queue) all validate the name.
## Expected-correct behavior
A leading-dash / invalid token is not a valid positional → reject it, matching the contract the rest of the CLI already enforces.
## Minimal repro
`parseProjectArgs(['status', '--foo'])` returned `{ subcommand: 'status', name: '--foo' }` (should throw `project: Unknown flag '--foo'.`).
## The fix
Add the leading-dash guard the `delete` branch already uses to the four project branches and the domain parser loop, and give `parseMiddlewareArgs` the same name regex (`/^[a-z_][a-z0-9_-]*$/`) its gen siblings already use. No legitimate positional (project slug, `dpl_` id, DNS hostname, middleware name) starts with `-`.
## Tests
Regression tests added (`project-args.test.ts`, new `domain-args.test.ts`, `gen-args.test.ts`): 6 unknown-flag rejections that fail on `origin/main` and pass after, plus happy-path/hyphenated-name guards. Local gate: the three arg test files 63/63; full `--project unit` zero-collateral vs a clean `origin/main` baseline (identical pre-existing adapter/init-migration failures, unrelated); `packages/void` typecheck + lint + fmt clean.
I enumerated every CLI parser to confirm these were the only three hand-rolled ones still swallowing invalid positionals (the rest use strict `parseArgs`, a subcommand allowlist, or a name regex), so the bug class is fully covered.
Prepared with AI assistance.
0 commit comments